Skip to contents

Inspired by this SO answer.

Usage

nth_group(x, n)

Arguments

x

grouped data frame

n

index(es) of the group(s) to extract

Value

subset of groups from the input dataframe

Examples

if (FALSE) { # \dontrun{
# extract first group
mtcars %>% group_by(cyl) %>% nth_group(1)

# extract first and third group
mtcars %>% group_by(cyl) %>% nth_group(c(1,3))
} # }