rollup
: A Tidy implementation of
grouping sets
, rollup
and cube
,
which are extensions of the group_by
clause that compute
multiple group_by
clauses in a single statement.
# From CRAN
install.packages("rollup")
# From Github
::install_github("JuYoungAhn/rollup") devtools
rollup
, please refer to
the Tutorial.%>% group_by(vs, am) %>% grouping_sets("vs","am",c("vs","am"),NA) %>%
mtcars summarize(n=n(), avg_mpg=mean(mpg))
%>% group_by(vs, am) %>% with_rollup() %>%
mtcars summarize(n=n(), avg_mpg=mean(mpg))
%>% group_by(vs, am) %>% with_cube() %>%
mtcars summarize(n=n(), avg_mpg=mean(mpg))