I have two vectors of equal length
a <- 1:10
b <- sample.int(10,size=10)
I would like to plot them into a matrix of the same length (10) where a is the row coordinate, b the column coordinate, with the value 1 for the coordinates and 0 for everything else. I have below a way to do this using a for loop, but was hoping to do this without a loop. Thanks!
matrix01 <- matrix(0, nrow = 10, ncol = 10)
for(i in 1:10) {
matrix01[i, b[i]] = 1
}