ft_split_levels {fctutils}R Documentation

Split Factor Levels into Multiple Factors

Description

Splits the levels of a factor vector into multiple factors based on a specified delimiter.

Usage

ft_split_levels(factor_vec, delimiter, names = NULL)

Arguments

factor_vec

A factor vector to split.

delimiter

A character string used to split the factor levels.

names

A character vector specifying names for the resulting factors. Default is NULL, in which case factors are named 'Factor1', 'Factor2', etc.

Value

A data frame containing the resulting factors.

Author(s)

Kai Guo

Examples

# Example factor vector
factor_vec <- factor(c('red_large', 'blue_small', 'green_medium'))

# Split levels into two factors
ft_split_levels(factor_vec, delimiter = '_')

[Package fctutils version 0.0.7 Index]