add_dummy_variables | R Documentation |
It uses 'tidyeval' and 'dplyr' to create dummy variables based for categorical variables.
add_dummy_variables(
df,
x,
values = c(),
auto_values = FALSE,
remove_original = TRUE
)
df |
A Local or remote data frame |
x |
Categorical variable |
values |
Possible known values of the categorical variable. If not passed then the function will take an additional step to figure the unique values of the variable. |
auto_values |
Safeguard argument to prevent the function from figuring the unique values if the values argument is empty. If it is ok for this function to obtain the unique values, set to TRUE. Defaults to FALSE. |
remove_original |
It removes the original variable from the returned table. Defaults to TRUE. |
library(dplyr)
mtcars %>%
add_dummy_variables(cyl, values = c(4, 6, 8))
mtcars %>%
add_dummy_variables(cyl, auto_values = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.