grouping_sets | R Documentation |
Compute total amounts at different group levels, producing multiple subtotals. With the 'grouping_sets' clause following 'group_by', you can aggregate multiple grouping variables in one operation. This reflects the 'GROUPING SETS' operations in 'SQL'.
grouping_sets(df, ...)
df |
dataframe or grouped df |
... |
grouping variables |
A list of 'grouped_df' class. each 'grouped_df' object has a different grouping level.
mtcars %>% group_by(vs, am) %>% grouping_sets("vs","am",c("vs","am"))
mtcars %>% group_by(vs, am) %>% with_rollup()
mtcars %>% group_by(vs, am) %>% with_cube()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.