spread_groups {ruler} | R 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 |
.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 = "__")
[Package ruler version 0.3.0 Index]