dummy_data {kerntools} | R Documentation |
Convert categorical data to dummies.
Description
Given a matrix or data.frame containing character/factors, this function performs one-hot-encoding.
Usage
dummy_data(X, lev = NULL)
Arguments
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. |
Value
X (class: "matrix") after performing one-hot-encoding.
Examples
summary(CO2)
CO2_dummy <- dummy_data(CO2[,1:3],lev=dummy_var(CO2[,1:3]))
CO2_dummy[1:10,1:5]
[Package kerntools version 1.2.0 Index]