Group a data frame by one or more variables. Supports standard and non standard evaluation.
df_group_by(data, ..., vars = NULL)
a data frame
One or more unquoted expressions (or variable names) separated by commas. Used to select a variable of interest.
a character vector containing the variable names of interest.
# Non standard evaluation
by_dose <- head(ToothGrowth) %>%
df_group_by(dose)
by_dose
#> # A tibble: 6 × 3
#> # Groups: dose [1]
#> len supp dose
#> <dbl> <fct> <dbl>
#> 1 4.2 VC 0.5
#> 2 11.5 VC 0.5
#> 3 7.3 VC 0.5
#> 4 5.8 VC 0.5
#> 5 6.4 VC 0.5
#> 6 10 VC 0.5
# Standard evaluation
head(ToothGrowth) %>%
df_group_by(vars = c("dose", "supp"))
#> # A tibble: 6 × 3
#> # Groups: dose, supp [1]
#> len supp dose
#> <dbl> <fct> <dbl>
#> 1 4.2 VC 0.5
#> 2 11.5 VC 0.5
#> 3 7.3 VC 0.5
#> 4 5.8 VC 0.5
#> 5 6.4 VC 0.5
#> 6 10 VC 0.5