Hi R-helpers,

I have been struggling with calculating row and column statistics,
e.g. standard deviation.

I know that
> datac$Mean<-rowMeans(datac,na.rm=TRUE)
will give me row means.

I have tried to replicate those row means with the apply function:
> datac$Mean2<-apply(datac,2,mean)

so that I can replace the function argument with "sd" (instead of
mean) to get standard deviations.

But, I'm running into this error:

> dim(datac)
[1]  17 271
> datac$Mean2<-apply(datac,2,mean)
Error in dimnames(x) <- dn :
  length of 'dimnames' [2] not equal to array extent


Can anyone see what I'm doing wrong?

Thanks!

Mark Na

______________________________________________
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.

Reply via email to