Skip to content
Prev 73620 / 398498 Next

help: how to get the position of a value in a matrix

Use which(..., arr.ind=TRUE); e.g.,
row col
[1,]   1   3
[2,]   2   3
[3,]   3   3
[4,]   3   4
[,1]       [,2]      [,3]      [,4]
[1,] 0.2148183 0.08251853 0.9444718 0.4487148
[2,] 0.5386863 0.49673282 0.8054240 0.5101593
[3,] 0.6252847 0.70974516 0.8858951 0.8590655

Andy