Title: | A Tidy Grouping Set Aggregation |
---|---|
Description: | A Tidy implementation of 'grouping sets', 'rollup' and 'cube' - extensions of the 'group_by' clause that allow for computing multiple 'group_by' clauses in a single statement. For more detailed information on these functions, please refer to "Enhanced Aggregation, Cube, Grouping and Rollup" <https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C+Grouping+and+Rollup>. |
Authors: | Ju Young Ahn [aut, cre] |
Maintainer: | Ju Young Ahn <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-02-25 03:00:05 UTC |
Source: | https://github.com/juyoungahn/rollup |
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, ...)
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()
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()
summarise
functionGeneric summarise
function
summarise(object, ...)
summarise(object, ...)
object |
Object to be summarized. |
... |
Additional arguments. |
An object of the same class as .data
. One grouping level will be dropped.
summarise
Default method for summarise
## S4 method for signature 'ANY' summarise(object, ...)
## S4 method for signature 'ANY' summarise(object, ...)
object |
An object |
... |
Additional arguments. |
An object of the same class as .data
. One grouping level will be dropped.
summarise
on grouped_df_listMethod for summarise
on grouped_df_list
## S4 method for signature 'grouped_df_list' summarise(object, ...)
## S4 method for signature 'grouped_df_list' summarise(object, ...)
object |
A grouped_df_list object. |
... |
Additional arguments. |
An object of the same class as .data.
One grouping level will be dropped.
summarize
functionGeneric summarize
function
summarize(object, ...)
summarize(object, ...)
object |
Object to be summarized. |
... |
Additional arguments. |
An object of the same class as .data
. One grouping level will be dropped.
'summarize_rollup' aggregates each 'grouped_df' in the 'grouped_df_list' class and return the unioned aggregated results.
summarize_rollup(df_list, ...)
summarize_rollup(df_list, ...)
df_list |
'grouped_df_list' class |
... |
functions for 'summarize' |
An object of the same class as .data
. The unioned aggregated result of multiple grouping levels will be dropped.
summarize
Default method for summarize
## S4 method for signature 'ANY' summarize(object, ...)
## S4 method for signature 'ANY' summarize(object, ...)
object |
An object. |
... |
Additional arguments. |
An object of the same class as .data
. One grouping level will be dropped.
summarize
on grouped_df_listMethod for summarize
on grouped_df_list
## S4 method for signature 'grouped_df_list' summarize(object, ...)
## S4 method for signature 'grouped_df_list' summarize(object, ...)
object |
A grouped_df_list object. |
... |
Additional arguments. |
An object of the same class as .data
. One grouping level will be dropped.
A dataset containing information about various web services.
web_service_data
web_service_data
A data frame with 30,000 rows and 6 variables:
date id
user id
gender
age band
pageview count
product view count (category)
Generated for example purposes
Compute total amounts at different group levels, producing multiple subtotals. With the 'with_cube' clause following 'group_by', you can aggregate multiple grouping variables in one operation. This reflects the 'WITH CUBE' operations in 'SQL'.
with_cube(grouped_df)
with_cube(grouped_df)
grouped_df |
'grouped_df' class |
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()
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()
Compute total amounts at different group levels, producing multiple subtotals. With the 'with_rollup' clause following 'group_by', you can aggregate multiple grouping variables in one operation. This reflects the 'WITH ROLLUP' operations in 'SQL'.
with_rollup(grouped_df)
with_rollup(grouped_df)
grouped_df |
'grouped_df' class |
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()
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()