- Joined
- 6/6/08
- Messages
- 1,194
- Points
- 58
Guys, quick question...
Say I have a matrix with ties for a certain value (max or min), but there's a tie. How do I get back the indices of those columns?
For instance, say our matrix is
434
122
331
I want my output to be:
1,3
2,3
1,2
Furthermore, if I have another matrix, I'd like to take those indices and add the corresponding column indices of those same rows.
So say our second matrix is:
235
159
672
I want my output to be:
7
14
13
What would be the syntax to do this?
Edit: for the record, the function apply(matrixName,1,which.max) does not work. It only returns one value at a time, and therefore, defeats the entire purpose.
Say I have a matrix with ties for a certain value (max or min), but there's a tie. How do I get back the indices of those columns?
For instance, say our matrix is
434
122
331
I want my output to be:
1,3
2,3
1,2
Furthermore, if I have another matrix, I'd like to take those indices and add the corresponding column indices of those same rows.
So say our second matrix is:
235
159
672
I want my output to be:
7
14
13
What would be the syntax to do this?
Edit: for the record, the function apply(matrixName,1,which.max) does not work. It only returns one value at a time, and therefore, defeats the entire purpose.