R summary function in ddply (plyr) in a simple way -
how replicate plyr
?
with(mtcars, tapply(mpg, cyl, summary))
with same elegance, i.e. without spelling out individual statistics?
library(plyr) dlply(mtcars, .(cyl), function(x) summary(x$mpg))
you data.frame, prefer on complex lists...
ddply(mtcars, .(cyl), function(x) summary(x$mpg)) # cyl min. 1st qu. median mean 3rd qu. max. # 1 4 21.4 22.80 26.0 26.66 30.40 33.9 # 2 6 17.8 18.65 19.7 19.74 21.00 21.4 # 3 8 10.4 14.40 15.2 15.10 16.25 19.2
Comments
Post a Comment