ft_intersect: Get Intersection of Factor Levels from Multiple Vectors

View source: R/fct_misc.R

ft_intersectR Documentation

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(...)

Arguments

...

Factor vectors to be intersected.

Value

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

Author(s)

Kai Guo

Examples

# 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)

fctutils documentation built on Oct. 1, 2024, 1:07 a.m.