Group Levels
group_levels.RdReturns a factor vector of grouping combinations. Return vector is same length as the number of rows in the data frame. levels of the factor can be lexically ordered or unordered.
Examples
#----------------------------------------------------------------------------
# group_levels() examples
#----------------------------------------------------------------------------
group_levels(mtcars, "cyl")
#> [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4
#> Levels: 4 6 8
group_levels(mtcars, c("cyl", "carb"))
#> [1] 6|4 6|4 4|1 6|1 8|2 6|1 8|4 4|2 4|2 6|4 6|4 8|3 8|3 8|3 8|4 8|4 8|4 4|1 4|2
#> [20] 4|1 4|1 8|2 8|2 8|4 8|2 4|1 4|2 4|2 8|4 6|6 8|8 4|2
#> Levels: 4|1 4|2 6|1 6|4 6|6 8|2 8|3 8|4 8|8