P.S.
If you want to use your function, revised, it may be a good idea: it's
faster
#write indexed mean function
meanfun <- function(x, inx, na.rm=FALSE) {
meanSD <- matrix(0, nrow=length(levels(inx)), ncol=length(3:ncol(x)))
for(i in 3:ncol(x)) {
meanSD[, i - 2] <
Hello,
I believe that the following solves it:
aggregate(SD[, 3:ncol(SD)], by=list(ID), mean)
aggregate(SD[, 3:ncol(SD)], by=list(ID), mean, na.rm=TRUE)
It's the second you want, it will compute the means for groups that aren't
only NA
and return NaN for groups with all values NA.
Rui Barradas
On Jan 9, 2012, at 12:02 AM, jawbonemurphy wrote:
Hi Dave,
Thanks for your response!
I'm new at R, and I'm afraid I'm not sure what you mean by:
?lapply
?"["
?order
It means I thought you might get the answers you needed by looking at
those functions' help pages.
Were these suggestio
Hi Dave,
Thanks for your response!
I'm new at R, and I'm afraid I'm not sure what you mean by:
?lapply
?"["
?order
Were these suggestions for other commands to try? If so, can you be more
specific? I apologize for being clueless :)
Secondly, you're right that the script I have now leaves me
On Jan 8, 2012, at 4:48 PM, jawbonemurphy wrote:
Hi,
I am trying to create a script that will evaluate each column of a
data
frame, regardless of # columns, using some function and sorting the
results
by an index vector:
?lapply
?"["
?order
#upload data (112 rows x 73 columns)
SD <- r
Hi,
I am trying to create a script that will evaluate each column of a data
frame, regardless of # columns, using some function and sorting the results
by an index vector:
#upload data (112 rows x 73 columns)
SD <- read.csv("/Users/johnjacob/Desktop/StudentsData_RInput.csv",
header=TRUE)
#assign
6 matches
Mail list logo