set_groups: set groups

Description Usage Arguments Details Examples

View source: R/groups.R

Description

set groups

Usage

1
set_groups(df, groups)

Arguments

df

data frame

groups

list of groups to pass to group_by_

Details

useful in tandem with 'capture_groups' when concerned about modification of groups by a function, for example when summarizing with dplyr Can easily capture and reset groups to maintain original grouping

Examples

1
2
3
4
5
6
7
## Not run: 
gTheoph <- dplyr::group_by(Theoph, Subject)
grps <- capture_groups(gTheoph) # capture subject
theoph_cmax <- summarize(gTheoph, cmax = max(conc)) # lose Subject grouping
theoph_cmax <- set_groups(theoph_cmax, grps) # resets the original "Subject" grouping

## End(Not run)

PKPDmisc documentation built on April 14, 2020, 5:49 p.m.