Learn R Programming

seplyr (version 1.0.4)

add_group_indices: Group a data frame and add per-group indices as a column.

Description

Group a data frame and add per-group indices as a column.

Usage

add_group_indices(.data, groupingVars, indexColumn)

Arguments

.data

data.frame

groupingVars

character vector of column names to group by.

indexColumn

character name of column to add indices to.

Value

.data with group identifying column added.

Examples

Run this code
# NOT RUN {
add_group_indices(datasets::mtcars, c("cyl", "gear"), 'groupID')

# }

Run the code above in your browser using DataLab