x <- factor(c("a", "a", "b", "c", "d", "b"))
sparse_dummy(x, one_hot = FALSE)
x <- factor(c("a", "a", "b", "c", "d", "b"))
sparse_dummy(x, one_hot = TRUE)
x <- factor(c("a", NA, "b", "c", "d", NA))
sparse_dummy(x, one_hot = FALSE)
x <- factor(c("a", NA, "b", "c", "d", NA))
sparse_dummy(x, one_hot = TRUE)
Run the code above in your browser using DataLab