vector_to_dummy.Rd
Create a dummy matrix based on the elements of a vector. Each column in the produced matrix is a dummy indicator.
vector_to_dummy(avector)
a numeric vector
A matrix of dummy variables
# let's say you have a list like this
num_vec = c(2, 3, 1, 4)
# get dummy matrix
vector_to_dummy(num_vec)
#> [,1] [,2] [,3] [,4]
#> [1,] 1 0 0 0
#> [2,] 1 0 0 0
#> [3,] 0 1 0 0
#> [4,] 0 1 0 0
#> [5,] 0 1 0 0
#> [6,] 0 0 1 0
#> [7,] 0 0 0 1
#> [8,] 0 0 0 1
#> [9,] 0 0 0 1
#> [10,] 0 0 0 1