set_groups: set groups

View source: R/groups.R

set_groupsR Documentation

set groups

Description

set groups

Usage

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

library(dplyr)
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

metrumresearchgroup/PKPDmisc documentation built on Oct. 21, 2022, 9:41 a.m.