R/group_cols.R

Defines functions group_cols

Documented in group_cols

#' Select Grouping Variables
#'
#' This selection helper matches grouping variables. It can be used within [select()] and [relocate()] selections.
#'
#' @seealso
#' [groups()] and [group_vars()] for retrieving the grouping variables outside selection contexts.
#'
#' @examples
#' mtcars %>% group_by(am, cyl) %>% select(group_cols())
#'
#' @export
group_cols <- function() {
  match(group_vars(select_env$.data), select_env$get_colnames())
}

Try the poorman package in your browser

Any scripts or data that you put into this service are public.

poorman documentation built on Nov. 2, 2023, 5:27 p.m.