https://github.com/hadley/dplyr
Raw File
Tip revision: 98b8a0f5de25e238ac97514da24ec228610c8701 authored by Lionel Henry on 19 January 2021, 09:23:23 UTC
Merge pull request #5686 from lionel-/fix-warning-overhead
Tip revision: 98b8a0f
group_data.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/group_data.R
\name{group_data}
\alias{group_data}
\alias{group_keys}
\alias{group_rows}
\alias{group_indices}
\alias{group_vars}
\alias{groups}
\alias{group_size}
\alias{n_groups}
\title{Grouping metadata}
\usage{
group_data(.data)

group_keys(.tbl, ...)

group_rows(.data)

group_indices(.data, ...)

group_vars(x)

groups(x)

group_size(x)

n_groups(x)
}
\arguments{
\item{.data, .tbl, x}{A data frame or extension (like a tibble or grouped
tibble).}

\item{...}{Use of \code{...} is now deprecated; please use \code{group_by()} first
instead.}
}
\description{
\itemize{
\item \code{group_data()} returns a data frame that defines the grouping structure.
The columns give the values of the grouping variables. The last column,
always called \code{.rows}, is a list of integer vectors that gives the
location of the rows in each group. You can retrieve just the grouping
data with \code{group_keys()}, and just the locations with \code{group_rows()}.
\item \code{group_indices()} returns an integer vector the same length as \code{.data}
that gives the group that each row belongs to (cf. \code{group_rows()} which
returns the rows which each group contains). \code{group_indices()} with no
argument is deprecated, superseded by \code{\link[=cur_group_id]{cur_group_id()}}.
\item \code{group_vars()} gives names of grouping variables as character vector;
\code{groups()} gives the names as a list of symbols.
\item \code{group_size()} gives the size of each group, and \code{n_groups()} gives the
total number of groups.
}

See \link{context} for equivalent functions that return values for the \emph{current}
group.
}
\examples{
df <- tibble(x = c(1,1,2,2))
group_vars(df)
group_rows(df)
group_data(df)
group_indices(df)

gf <- group_by(df, x)
group_vars(gf)
group_rows(gf)
group_data(gf)
group_indices(gf)
}
\keyword{internal}
back to top