ft_apply {fctutils} | R Documentation |
Apply a Function to Factor Levels
Description
Transforms factor levels by applying a function to each level.
Usage
ft_apply(factor_vec, apply_func)
Arguments
factor_vec |
A factor vector to transform. |
apply_func |
A function to apply to each level. |
Value
A factor vector with transformed levels.
Author(s)
Kai Guo
Examples
# Example factor vector
factor_vec <- factor(c('apple', 'banana', 'cherry'))
# Append '_fruit' to each level
ft_apply(factor_vec, function(x) paste0(x, '_fruit'))
[Package fctutils version 0.0.7 Index]