[R] Aggregate with multiple statistics?
hadley wickham
h.wickham at gmail.com
Sat Oct 21 02:09:26 CEST 2006
> Try summaryBy in package doBy. e.g. using the built in dataset CO2:
>
> summaryBy(uptake ~ Plant, CO2, FUN = c(mean, min, max))
Or with reshape with a little more work:
cm <- melt(CO2, id=1:4)
cast(cm, Type ~ Treatment, c(min,mean,max))
but you get some extra flexibility:
cast(cm, result_variable + Type ~ Treatment, c(min,mean,max))
cast(cm, Type ~ Treatment ~ result_variable, c(min,mean,max))
cast(cm, Type + Treatment ~ result_variable, c(min,mean,max))
Regards,
Hadley
More information about the R-help
mailing list