powered by
Transforms factor levels by applying a function to each level.
ft_apply(factor_vec, apply_func)
A factor vector with transformed levels.
A factor vector to transform.
A function to apply to each level.
Kai Guo
# Example factor vector factor_vec <- factor(c('apple', 'banana', 'cherry')) # Append '_fruit' to each level ft_apply(factor_vec, function(x) paste0(x, '_fruit'))
Run the code above in your browser using DataLab