[R] tapply and empty subsets
jasont@indigoindustrial.co.nz
jasont at indigoindustrial.co.nz
Wed May 15 01:13:53 CEST 2002
> I guess for my purpose the following will do.
>
> > x <- tapply(y, z, mean)
> > x[is.na(x)] <- 0
>
> Thanks,
> Giovanni
If I might ask, what's wrong with NA? I occasionally deal with data sets that
do have means close to zero, so my doing this would be misleading at best
(YMMV). NA is a good thing, for me.
If you just can't live with NA, na.omit(tapply(y,z,mean)) might be more
appropriate here.
Cheers
Jason
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list