I have the following matrix:
m = matrix( c("l","K","p","j",
"f","n","n","i",
"l","n","n","c",
"a","g","r","s"),nrow=4,byrow=TRUE )
I know that m[2,3]
equals "n"
.
How can I get the corresponding index number? By that I mean, how can I get the index
that will give me the value of the matrix at that position (2nd row, 3rd column). In this case it would be 10, because m[10] will give me back the "n" at the position in the 2nd row and the 3rd column.
I would be glad if the solution would work also for the case that I have only the row and column name(if rows and columns have been named) that identify a certain position in the matrix.