ft_rename_levels | R Documentation |
Renames the levels of a factor vector based on a mapping provided in a data frame.
ft_rename_levels(factor_vec, mapping_df)
factor_vec |
A factor vector to modify. |
mapping_df |
A data frame with two columns: 'old' and 'new', representing old and new level names. |
A factor vector with levels renamed.
Kai Guo
# Example factor vector
factor_vec <- factor(c('A', 'B', 'C'))
# Mapping data frame
mapping_df <- data.frame(old = c('A', 'B'), new = c('Alpha', 'Beta'))
# Rename levels
ft_rename_levels(factor_vec, mapping_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.