nth_group: Extract nth (or multiple sub-) group

View source: R/nth_group.R

nth_groupR Documentation

Extract nth (or multiple sub-) group

Description

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

## Not run: 
# extract first group
mtcars %>% group_by(cyl) %>% nth_group(1)

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

## End(Not run)


espinielli/scrap documentation built on Dec. 9, 2023, 11:25 p.m.