HI,
You can also use these in addition to aggregate:
tapply(dat$x,INDEX=dat[grp],mean)
library(plyr)
ddply(dat,.(dat[grp]$a,dat[grp]$d),summarize,mean(x))
# dat[grp]$a dat[grp]$d ..1
#1 b c 0.26781378
#2 b d -0.01994023
#3 c e 0.1487
Replace
lst <- paste('dat$', grp, sep='', collapse =',')
aggregate(dat$x, list(lst), mean)
with
aggregate(dat$x, dat[grp], mean)
The 'by' argument to aggregate should be a list
and data.frames (like dat and dat[grp]) are lists.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -
2 matches
Mail list logo