add_group_column.Rd
This function adds a new column to a data frame with a specified name. The new column indicates groups based on the grouping variables provided. When no grouping variable is provided, a default value is assigned to the new column.
add_group_column(data, name, group_by = NULL)
A data frame.
The name of the new column to be added.
A vector of strings specifying the column names used for grouping. Default is NULL.
A data frame with the new column added.
if (FALSE) {
data <- data.frame(x = c(1,2,3,1,2,3), y = c("a","b","c","a","b","c"))
data %>% add_group_column(name = "group_id", group_by = c("x", "y"))
}