group_cols {dplyr}R Documentation

Select grouping variables

Description

This selection helpers matches grouping variables. It can be used in select() or vars() selections.

Usage

group_cols(vars = peek_vars())

Arguments

vars

A character vector of variable names. When called from inside selecting functions like dplyr::select() these are automatically set to the names of the table.

See Also

groups() and group_vars() for retrieving the grouping variables outside selection contexts.

Examples

gdf <- iris %>% group_by(Species)

# Select the grouping variables:
gdf %>% select(group_cols())

# Remove the grouping variables from mutate selections:
gdf %>% mutate_at(vars(-group_cols()), `/`, 100)

[Package dplyr version 0.8.5 Index]