spread_groups: Spread grouping columns

View source: R/spread-groups.R

spread_groupsR Documentation

Spread grouping columns

Description

Function that is used during interpretation of group pack output. It converts grouped summary into column pack format.

Usage

spread_groups(.tbl, ..., .group_sep = ".", .col_sep = "._.")

Arguments

.tbl

Data frame with result of grouped summary.

...

A selection of grouping columns (as in tidyr::unite()).

.group_sep

A string to be used as separator of grouping levels.

.col_sep

A string to be used as separator in column pack.

Details

Multiple grouping variables are converted to one with tidyr::unite() and separator .group_sep. New values are then treated as variable names which should be validated and which represent the group data as a whole.

Value

A data frame in column pack format.

Examples

mtcars_grouped_summary <- mtcars %>%
  dplyr::group_by(vs, am) %>%
  dplyr::summarise(n_low = dplyr::n() > 6, n_high = dplyr::n() < 10)

spread_groups(mtcars_grouped_summary, vs, am)

spread_groups(mtcars_grouped_summary, vs, am, .group_sep = "__")

spread_groups(mtcars_grouped_summary, vs, am, .col_sep = "__")

echasnovski/ruler documentation built on April 3, 2023, 4:17 p.m.