I have a 100x5 matrix, let's call it d. Here are the contents of d:
[,1] [,2] [,3] [,4] [,5]
[1,] 192.3273 152.8275 158.7368 199.9222 209.09283
[2,] 155.8720 157.3843 153.9376 248.1005 212.35851
[3,] 228.1295 130.2183 260.8789 314.3371 54.35375
[4,] 173.6735 111.3873 238.1540 194.9216 172.86597
[5,] 219.6467 276.0814 347.3341 345.8772 163.06900
[6,] 195.2154 223.5708 289.9555 288.3098 116.04556
I want to get the minimum value of each row, which I can get easily using
apply(d, 1, min)
What I also want to get is the column number of the minimum value. So a vector of values from 1-5 which correspond to minimum value in each row.
Additionally is there anything more efficient that the apply function?
Ben