I\'m trying to use R\'s by command to get column means for subsets of a data frame. For example, consider this data frame:
by
> z = data.frame(
The output of by is a list so you can use do.call to rbind them and then convert this:
list
do.call
rbind
as.data.frame(do.call("rbind",by(z[,2:5],z$labels,colMeans))) data.1 data.2 data.3 data.4 a 1.5 6.5 11.5 16.5 b 3.0 8.0 13.0 18.0 c 4.5 9.5 14.5 19.5