fct_encode_one_hot: Encode a factor as a one-hot indicator matrix
Description
fct_encode_one_hot() encodes a factor as a one-hot indicator matrix.
This matrix consists of length(x) rows and length(levels(x)) columns.
Every value in row i of the matrix is filled with 0L except for the
column that has the same name as x[[i]], which is instead filled with 1L.
Usage
fct_encode_one_hot(x)
Value
An integer matrix with length(x) rows and length(levels(x))
columns.
Arguments
x
A factor.
x can't contain missing values.
x is allowed to be an ordered factor.
Details
The columns are returned in the same order as levels(x).
If x has names, the names are propagated onto the result as the row names.