add_group_summaries: Simulate the group_by/mutate pattern with an explicit...

Description Usage Arguments Value Examples

View source: R/add_group_summaries.R

Description

Group a data frame by the groupingVars and compute user summaries on this data frame (user summaries specified in ...), then join these new columns back into the original data and return to the user. Author: John Mount, Win-Vector LLC.

Usage

1
add_group_summaries(d, groupingVars, ..., arrangeTerms = NULL)

Arguments

d

data.frame

groupingVars

character vector of column names to group by.

...

list of dplyr::mutate() expressions.

arrangeTerms

character optional vector of column expressions to arrange by.

Value

d with grouped summaries added as extra columns

Examples

1
2
3
4
5
add_group_summaries(datasets::mtcars,
                    c("cyl", "gear"),
                    group_mean_mpg = mean(mpg),
                    group_mean_disp = mean(disp)) %.>%
  head(.)

seplyr documentation built on Sept. 5, 2021, 5:12 p.m.