I wish to subset a matrix/ data.frame with a set of indices that I have. For instance if I do:
a=matrix(1:20,4)
a[1:2,1:2]
[,1] [,2]
[1,] 1 5
[2,] 2 6
However, I was hoping to only get a[1,1] and a[2,2] only. How can you do this in R without using a for loop.