https://github.com/hadley/dplyr
Tip revision: 2708de6009e29bfa8e93d69b92e0da05a0c3c484 authored by Romain Francois on 20 November 2020, 09:52:32 UTC
rethrow shiny errors as is, instead of promoting them like other errors.
rethrow shiny errors as is, instead of promoting them like other errors.
Tip revision: 2708de6
group_trim.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/group_trim.R
\name{group_trim}
\alias{group_trim}
\title{Trim grouping structure}
\usage{
group_trim(.tbl, .drop = group_by_drop_default(.tbl))
}
\arguments{
\item{.tbl}{A \link[=grouped_df]{grouped data frame}}
\item{.drop}{See \code{\link[=group_by]{group_by()}}}
}
\value{
A \link[=grouped_df]{grouped data frame}
}
\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.
\code{group_trim()} is particularly useful after a \code{\link[=filter]{filter()}} that is intended
to select a subset of groups.
}
\examples{
iris \%>\%
group_by(Species) \%>\%
filter(Species == "setosa", .preserve = TRUE) \%>\%
group_trim()
}
\seealso{
Other grouping functions:
\code{\link{group_by}()},
\code{\link{group_map}()},
\code{\link{group_nest}()},
\code{\link{group_split}()}
}
\concept{grouping functions}