[R] mean fn in combination with by() XXXX

Dan Abner dan.abner99 at gmail.com
Thu Apr 10 14:49:41 CEST 2014

 Hi all,

Can anyone please explain the following results (why does median()
work here but not mean())? Is there a fix or work around for this?



> by(urpdata[,2],urpdata[,12],mean,na.rm=TRUE)
Error in FUN(X[[1L]], ...) : could not find function "FUN"
> by(urpdata[,2],urpdata[,12],median,na.rm=TRUE)
urpdata[, 12]: post
[1] 64
urpdata[, 12]: pre
[1] 83

More information about the R-help mailing list