On Jul 20, 2010, at 9:13 AM, Marcus Drescher wrote:
Hi all,
I have a dataframe with survey data. Now I want to calculate means
from several but not all columns (e.g. a1, a2, a3) and save them in
a new separate column (e.g. a).
Well that would be possible unless you are in Minitab or Excel where
you can put stuff of variable length where ever.
Like: a = mean(a1, a2, a3)
Can someone help me or give me the right key word to look for?
?colMeans
Perhaps:
meansvec <- colMeans(dfrm[ , c("a1", "a2", "a3")] )
If on the other hand, you wanted rowMeans (since your problems
specification was rather ambiguous) that function is also available.
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.