group: Grouped Data

Description Usage Arguments Details Value See Also Examples

View source: R/group.R

Description

Group the rows in a dataset according to a specified factor or set of factors.

Usage

1
2
3
4
5
group(`_data`, ...)
## Default S3 method:
group(`_data`, ...)
## S3 method for class 'dataset'
group(`_data`, ...)

Arguments

_data

object to be grouped.

...

grouping factors for the rows.

Details

group is a generic method that splits the rows in a data set according to a grouping factor (the additional ... arguments). These arguments get evaluated in the scope of the _data argument using the scope function.

Commonly, the next operation after a call to group will be a call to do that operates on the groups of rows.

Value

A single-variable dataset with rows corresponding to the distinct combinations of the grouping factors. Each list entry is a dataset of rows that share the same grouping factor values. The keys of the result are the grouping factors.

See Also

do, lscope, split.

Examples

1
2
3
4
5
6
7
# split into groups
x <- group(mtcars, gear, cyl)

# entries share the same grouping factors
x[[1]][[1]]

x[[1]][[2]]

patperry/r-frame documentation built on May 6, 2019, 8:34 p.m.