Make n hot vector.
nHot(x, len, out = "matrix")
| x | [ |
|---|---|
| len | [ |
| out | [ |
[matrix(1, len)] A one-row matrix with len columns with every
entry 0 except the columns specified by x which are 1.
nHot(c(1, 3), 5)#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 0 1 0 0nHot(c(1, 3), 5, out = "vector")#> [1] 1 0 1 0 0