One-hot encode a factor variable

one_hot(labels)

Arguments

labels

factor
Factor to encode.

Value

integer

Integer vector of encoded labels.

Examples

 if (FALSE) {
 one_hot(factor(c("a", "b", "a")))
 }