Learn R Programming

fctutils (version 0.0.7)

ft_unique_comb: Create Factor of Unique Combinations from Multiple Factors

Description

Generates a new factor where each level represents a unique combination of levels from the input factors.

Usage

ft_unique_comb(..., sep = "_")

Value

A factor vector representing unique combinations.

Arguments

...

Factor vectors to combine.

sep

A string to separate levels in the combined factor. Default is '_'.

Author

Kai Guo

Examples

Run this code
# Example factors
factor_vec1 <- factor(c('A', 'A', 'B', 'B'))
factor_vec2 <- factor(c('X', 'Y', 'X', 'Y'))

# Create unique combinations
combined_factor <- ft_unique_comb(factor_vec1, factor_vec2)
levels(combined_factor)

Run the code above in your browser using DataLab