ft_encode | R Documentation |
Converts the levels of a factor vector into numeric codes, optionally using a provided mapping.
ft_encode(factor_vec, mapping = NULL)
factor_vec |
A factor vector to encode. |
mapping |
An optional named vector providing the numeric code for each level. |
A numeric vector with encoded values.
Kai Guo
# Example factor vector
factor_vec <- factor(c('low', 'medium', 'high', 'medium'))
# Encode without mapping
ft_encode(factor_vec)
# Encode with custom mapping
custom_mapping <- c('low' = 1, 'medium' = 2, 'high' = 3)
ft_encode(factor_vec, mapping = custom_mapping)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.