dummy_data {kerntools} | R Documentation |
Given a matrix or data.frame containing character/factors, this function performs one-hot-encoding.
dummy_data(X, lev = NULL)
X |
A matrix, or a data.frame containing factors. (If the columns are of any other class, they will be coerced into factors anyway). |
lev |
(optional) A vector with the categories ("levels") of each factor. |
X (class: "matrix") after performing one-hot-encoding.
summary(CO2)
CO2_dummy <- dummy_data(CO2[,1:3],lev=dummy_var(CO2[,1:3]))
CO2_dummy[1:10,1:5]