add_dummy_variables {modeldb} | R Documentation |
Creates dummy variables
Description
It uses 'tidyeval' and 'dplyr' to create dummy variables based for categorical variables.
Usage
add_dummy_variables(
df,
x,
values = c(),
auto_values = FALSE,
remove_original = TRUE
)
Arguments
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. |
Examples
library(dplyr)
mtcars %>%
add_dummy_variables(cyl, values = c(4, 6, 8))
mtcars %>%
add_dummy_variables(cyl, auto_values = TRUE)
[Package modeldb version 0.3.0 Index]