I would like to be able to use dplyr\'s split-apply-combine strategy to the apply the summary() command.
Take a simple data frame:
You can use the SE version of data_frame, that is, data_frame_ and perform:
df %>%
group_by(class) %>%
do(data_frame_(summary(.$value)))
Alternatively, you can use as.list() wrapped by data.frame() with the argument check.names = FALSE:
df %>%
group_by(class) %>%
do(data.frame(as.list(summary(.$value)), check.names = FALSE))
Both versions produce:
# Source: local data frame [2 x 7]
# Groups: class [2]
#
# class Min. 1st Qu. Median Mean 3rd Qu. Max.
# (fctr) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
# 1 A 100 105 110 110 115 120
# 2 B 800 820 840 840 860 880