[R] Finding row in matrix with minimum column

Jorge Ivan Velez
Thu, 19 May 2011 02:51:31 -0000

Hi Worik,

See ?which.min

x <- matrix(c(7, 7, 9, 7, 7, 9, 2, 9), ncol = 2, byrow = FALSE)
which.min(x[,2])
x[which.min(x[,2]), ]


HTH,
Jorge

On Wed, May 18, 2011 at 10:38 PM, Worik R <> wrote:

> Friends
>
> If I have a matrix such as...
>
>     [,1] [,2]
> [1,]    7    7
> [2,]    7    9
> [3,]    9   2
> [4,]    7    9
>
> And I want to find the row number that has the minimum value of column 2
> (row 3 in this  case) how can I do it?  Is there a simple way?
>
> cheers
> Worik
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]