dummy_vars | R Documentation |
Create dummy/indicator variables for all categorical variables in a data.frame. Can be used as a pre-processing step before calling other functions within the package.
dummy_vars(df)
df |
a data.frame on which to make dummy variables for each categorical/factor variable, based on contrasts. |
a data.frame matching df
but where each categorical
variable in df
is replaced with indicator variables. All
combinations of the indicator/dummy variable are returned. Naming
convention of the new dummy variables is variable_level. For example, a
factor variable in df
named "colour" with levels "red", "green" and
"purple" will be replaced with three columns (the new dummy variables),
named colour_red, colour_green and colour_purple.
pred_input_info
dummy_vars(data.frame("Colour" = factor(sample(c("red",
"azure",
"green",
"white"),
500,
replace = TRUE))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.