I'm trying to get the value of a matrix with a vector of row indexes and column indexes like this.
M = matrix(rnorm(100),nrow=10,ncol=10)
set.seed(123)
row_index = sample(10) # 3 8 4 7 6 1 10 9 2 5
column_index = sample(10) # 10 5 6 9 1 7 8 4 3 2
Is there any way I can do something like
M[row_index, column_index]
and get the values for
M[3,10], M[8,5], ...
as a vector?