groups_colnums {poputils} | R Documentation |
Get a named vector of column indices for the grouping variables in a grouped data frame
Description
Constructed a named vector of indices equivalent to the vectors produced by tidyselect::eval_select, but for the grouping variables in an object of class "grouped_df".
Usage
groups_colnums(data)
Arguments
data |
A data frame. |
Details
If data
is not grouped, then groups_colnums
returns a zero-length vector.
Value
A named integer vector.
Examples
library(dplyr)
df <- data.frame(x = 1:4,
g = c(1, 1, 2, 2))
groups_colnums(df)
df <- group_by(df, g)
groups_colnums(df)
[Package poputils version 0.3.1 Index]