ft_filter_func {fctutils} | R Documentation |
Filter Factor Levels Using a Function
Description
Removes levels from a factor vector based on a user-defined function.
Usage
ft_filter_func(factor_vec, func)
Arguments
factor_vec |
A factor vector to filter. |
func |
A function that takes a character vector of levels and returns a logical vector. |
Value
A factor vector with levels filtered according to the function.
Author(s)
Kai Guo
Examples
# Example factor vector
factor_vec <- factor(c('apple', 'banana', 'cherry', 'date'))
# Remove levels that start with 'b'
ft_filter_func(factor_vec, function(x) !grepl('^b', x))
[Package fctutils version 0.0.7 Index]