powered by
Removes levels from a factor vector based on a user-defined function.
ft_filter_func(factor_vec, func)
A factor vector with levels filtered according to the function.
A factor vector to filter.
A function that takes a character vector of levels and returns a logical vector.
Kai Guo
# 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))
Run the code above in your browser using DataLab