Let\'s say you have a matrix
m <- matrix(1:25*2, nrow = 5, ncol=5)
How do you go from matrix subscripts (row index, column index) to a lin
There are row and col functions that return those indices in matrix form. So it should be as simple as indexing the return from those two functions:
M<- matrix(1:6, 2) row(M)[5] #[1] 1 col(M)[5] #[1] 3 rc.ind <- function(M, ind) c(row(M)[ind], col(M)[ind] ) rc.ind(M,5) [1] 1 3