onehot {onehot} | R Documentation |
Onehot encode a data.frame
onehot(data, stringsAsFactors = FALSE, addNA = FALSE, max_levels = 10)
data |
data.frame to convert factors into onehot encoded columns |
stringsAsFactors |
if TRUE, converts character vectors to factors |
addNA |
if TRUE, adds NA to factors as a level |
max_levels |
maximum number of levels to onehot encode per factor variable. Factors with levels exceeding this number will be skipped. |
a onehot
object descrbing how to transform the data
data(iris) encoder <- onehot(iris) ## add NAs to factors encoder <- onehot(iris, addNA=TRUE) ## Convert character fields to factrs encoder <- onehot(iris, stringsAsFactors=TRUE) ## limit which factors are onehot encoded encoder <- onehot(iris, max_levels=5)