one.hot | R Documentation |
One-Hot-Encode unordered factor columns of a data.frame, matrix, or data.table, using the
mltools::one_hot()
mltools::one_hot function.
one.hot(data, cols = "auto", sparsifyNAs = FALSE, naCols = FALSE,
dropCols = TRUE, dropUnusedLevels = FALSE)
data |
a numerical |
cols |
a character vector of column names or indices to one-hot-encode. If |
sparsifyNAs |
a logical value indicating whether to converte NAs to 0s. |
naCols |
a logical value indicating whether to create a separate column for NAs. |
dropCols |
a logical value indicating whether to drop the original columns which are one-hot-encoded. |
dropUnusedLevels |
a logical value indicating whether to drop unused factor levels. |
Reza Mohammadi a.mohammadi@uva.nl and Kevin Burke kevin.burke@ul.ie
scaler
data(risk)
str(risk)
risk_oh <- one.hot(risk, cols = "auto")
str(risk_oh)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.