set_groups | R Documentation |
set groups
set_groups(df, groups)
df |
data frame |
groups |
list of groups to pass to group_by_ |
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
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.