Is there a way I can select a bunch of prespecified elements all at once from a matrix? Specifically, suppose I have the following matrix:
58 59
A similar solution to that posted above, but one that deals with the situation of having a vector for the rows and a vector for the columns (which was my question when I came upon this thread) is as follows:
> rows <- c(1,2,3,4,5)
> cols <- c(2,3,4,5,6)
> call <- cbind(rows,cols)
>
> mat[call]
[1] 3.772139 3.755554 5.999409 3.810169 3.796884