group_trim: Trim grouping structure

Description Usage Arguments Value See Also Examples

View source: R/group_trim.R

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("experimental")}

Drop unused levels of all factors that are used as grouping variables, then recalculates the grouping structure.

group_trim() is particularly useful after a filter() that is intended to select a subset of groups.

Usage

1
group_trim(.tbl, .drop = group_by_drop_default(.tbl))

Arguments

.tbl

A grouped data frame

.drop

See group_by()

Value

A grouped data frame

See Also

Other grouping functions: group_by(), group_map(), group_nest(), group_split()

Examples

1
2
3
4
iris %>%
  group_by(Species) %>%
  filter(Species == "setosa", .preserve = TRUE) %>%
  group_trim()

javifar/TIDYVERSE-DPLYR documentation built on Dec. 20, 2021, 9:08 p.m.