df <- tidytable(
chr = c("a", "b", NA),
fct = as.factor(c("a", NA, "c")),
num = 1:3
)
# Automatically does all character/factor columns
df %>%
get_dummies()
df %>%
get_dummies(cols = chr)
df %>%
get_dummies(cols = c(chr, fct), drop_first = TRUE)
df %>%
get_dummies(prefix_sep = ".", dummify_na = FALSE)
Run the code above in your browser using DataLab