Learn R Programming

fctutils (version 0.0.7)

ft_intersect: Get Intersection of Factor Levels from Multiple Vectors

Description

Combines multiple factor vectors and returns a factor vector containing only the levels common to all.

Usage

ft_intersect(...)

Value

A factor vector containing the intersection of levels from all provided factors.

Arguments

...

Factor vectors to be intersected.

Author

Kai Guo

Examples

Run this code
# Example factor vectors
factor_vec1 <- factor(c('apple', 'banana', 'cherry'))
factor_vec2 <- factor(c('banana', 'date', 'cherry'))
factor_vec3 <- factor(c('banana', 'cherry', 'fig'))

# Get intersection of levels
ft_intersect(factor_vec1, factor_vec2, factor_vec3)

Run the code above in your browser using DataLab