data(risk)
str(risk)
risk_one_hot <- one.hot(risk, cols = "auto")
str(risk_one_hot)
# Missing values and unused factor levels
example_data <- data.frame(
color = factor(c("red", NA, "blue"), levels = c("blue", "green", "red"))
)
one.hot(example_data, sparsifyNAs = TRUE, naCols = TRUE,
dropCols = TRUE, dropUnusedLevels = TRUE)
Run the code above in your browser using DataLab