ft_dummy | R Documentation |
Generates a data frame of dummy variables (one-hot encoded) from a factor vector.
ft_dummy(factor_vec)
factor_vec |
A factor vector. |
A data frame where each column represents a level of the factor, containing 1s and 0s.
Kai Guo
# Example factor vector
factor_vec <- factor(c('apple', 'banana', 'apple', 'cherry'))
# Create dummy variables
ft_dummy(factor_vec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.