Description Usage Arguments Note Examples
This function is used identically to dplyr::summarize. However, it applies the grouping variables of .data additively and returns summary values at each level. The returned dataset contains an additional variable 'level' that tracks the number of grouping variables applied. Note that the function additively applies grouping variables in the order that they were originally specified. It does not do combinations of levels. In other words, a dataset with three grouping variables, 'a', 'b', and 'c', would return level 0: ungroup(), level 1: group_by('a'), level 2: group_by ('a', 'b') and level 3: group_by('a', 'b', 'c')
1 | summarize_multi(.data, ..., level = "level_")
|
.data |
the data frame to be summarised |
... |
further arguments of the form var = value |
level |
name of created variable tracking summary levels. Default is 'level_' |
by default this function creates a variable called "level_" that tracks the levels of the groupings. If this conflicts with your dataset it can be renamed using the level parameter.
1 2 3 | summarize_multi(iris, mean_sepal = mean(Sepal.Length))
summarize_multi(iris %>% dplyr::group_by(Species), mean_sepal = mean(Sepal.Length))
summarize_multi(iris %>% dplyr::group_by(Species, Petal.Width), mean_sepal = mean(Sepal.Length))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.