[R] Newbie: how to calculate group averagege?
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Apr 10 13:21:20 CEST 2000
Sven Garbade <garbade at psy.uni-muenchen.de> writes:
> For each combinations of the factors are 6 values of rt. I need the mean
> of the six rt values for each factor combination. I´ve tried the ave()
> function:
>
> > ave(rt, zf, xf, yf)
>
> but it returns a lot of NAs. Is there another r-function I´ve overlooked
> or must I write my own function?
I think you're looking for
tapply(rt,list(zf, xf, yf), mean, na.rm=T)
alternatively,
ave(rt, zf, xf, yf, FUN=function(x)mean(x,na.rm=T))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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