[R] search in matrix

From: Florent Bresson <f_bresson_at_yahoo.fr>
Date: Fri 30 Dec 2005 - 03:20:52 EST


I'm dealing with a matrix like :

     "x"  "y"  "z"

[1,] 2 4 1
[2,] 6 1 2
...
[n,] 7 3 1

For each row I would like to know the header of the column which corresponds to the minimum value. In the case of my matrix, I would like to obtain the following vector :

z y ... z

Any idea ?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Dec 30 03:26:28 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:44 EST