Captures groups as decorations for class 'data.frame'.
Creates a sequentially-valued integer attribute
with name 'groups' for each corresponding column
(after clearing all such existing designations).
It is an error if not all such columns are present.
Defaults to groups(x). If no columns are
specified and x has no groups, x is returned
with any existing column-level 'groups' attributes
removed.
Usage
# S3 method for class 'data.frame'
decorate_groups(x, ...)See also
Other decorate:
as_decorated(),
as_decorated.default(),
decorate(),
decorate.character(),
decorate.data.frame(),
decorate.list(),
decorate_groups(),
decorations(),
decorations.data.frame(),
decorations_groups(),
decorations_groups.data.frame(),
group_by_decorations(),
group_by_decorations.data.frame(),
redecorate(),
undecorate(),
undecorate.default()
Examples
library(magrittr)
library(dplyr)
Theoph %>% decorate_groups(Subject, Time) %>% groups # nothing!
#> list()
Theoph %>% decorate_groups(Subject, Time) %>% decorations # note well
#> - Subject
#> - groups: 1
#> - Wt:
#> - Dose:
#> - Time
#> - groups: 2
#> - conc:
Theoph %>% group_by(Subject, Time) %>% decorate_groups %>% decorations # same
#> - Subject
#> - groups: 1
#> - Wt:
#> - Dose:
#> - Time
#> - groups: 2
#> - conc: