I have a matrix indicating in which column there should be a value 1. All other columns should have a value of 0. For example,
m = matrix(c(3,3,3,5,12,13),nrow = 3)
How should I efficitietly create the following matrix?
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[,1] 0 0 1 0 1 0 0 0 0 0 0 0 0 0
[,2] 0 0 1 0 0 0 0 0 0 0 0 1 0 0
[,3] 0 0 1 0 0 0 0 0 0 0 0 0 1 0
Thank you