# NOT RUN {
library(data.table)
dt <- data.table(
ID = 1:4,
color = factor(c("red", NA, "blue", "blue"), levels=c("blue", "green", "red"))
)
one_hot(dt)
one_hot(dt, sparsifyNAs=TRUE)
one_hot(dt, naCols=TRUE)
one_hot(dt, dropCols=FALSE)
one_hot(dt, dropUnusedLevels=TRUE)
# }
Run the code above in your browser using DataLab