powered by
Splits the levels of a factor vector into multiple factors based on a specified delimiter.
ft_split_levels(factor_vec, delimiter, names = NULL)
A data frame containing the resulting factors.
A factor vector to split.
A character string used to split the factor levels.
A character vector specifying names for the resulting factors. Default is NULL, in which case factors are named 'Factor1', 'Factor2', etc.
NULL
Kai Guo
# Example factor vector factor_vec <- factor(c('red_large', 'blue_small', 'green_medium')) # Split levels into two factors ft_split_levels(factor_vec, delimiter = '_')
Run the code above in your browser using DataLab