I have 4 matrices with random values for example -
Matrix 1 Matrix 2 Matrix 3 Matrix 4
[,1] [,2] [,3] [,1] [,2] [,3] [,1] [,2] [,3] [,1] [,2] [,3]
[1,] 10 21 36 [1,] 10 13 100 [1,] 12 16 12 [1,] 61 12 20
[2,] 15 21 45 [2,] 12 47 10 [2,] 16 51 10 [2,] 21 15 400
[3,] 46 23 102 [3,] 54 50 42 [3,] 17 73 14 [3,] 13 31 12
I want to select only the rows which has the highest value in the 3rd column [,3] - Here I want a final matrix as displayed below -
Final Matrix
[,1] [,2] [,3]
[1,] 10 13 100
[2,] 21 15 400
[3,] 46 23 102
Some suggestions would be helpful using subset() or other functions in R?