Group a data frame by the groupingVars and compute user summaries on this data frame (user summaries specified in ...). Enforces the good dplyr pipeline design principle of keeping group_by and summarize close together. Author: John Mount, Win-Vector LLC.

group_summarize(
  d,
  groupingVars,
  ...,
  arrangeTerms = NULL,
  env = parent.frame()
)

group_summarise(
  d,
  groupingVars,
  ...,
  arrangeTerms = NULL,
  env = parent.frame()
)

Arguments

d

data.frame

groupingVars

character vector of column names to group by.

...

list of dplyr::mutate() expressions.

arrangeTerms

character optional vector of quoted column expressions to arrange by.

env

environment to work in.

Value

d summarized by groups

Examples

group_summarize(datasets::mtcars, c("cyl", "gear"), group_mean_mpg = mean(mpg), group_mean_disp = mean(disp)) %.>% head(.)
#> # A tibble: 6 x 4 #> cyl gear group_mean_mpg group_mean_disp #> <dbl> <dbl> <dbl> <dbl> #> 1 4 3 21.5 120. #> 2 4 4 26.9 103. #> 3 4 5 28.2 108. #> 4 6 3 19.8 242. #> 5 6 4 19.8 164. #> 6 6 5 19.7 145