Re: [R] Finding the Min.

From: Jarimatti Valkonen <>
Date: Tue 30 Jan 2007 - 09:00:54 GMT

stat stat wrote:

> I want to see at which row minimum value of the second column occures.
> Therefore I made the following loop:

[snip while-loop]

> Is there any more effective way to do that in terms of time consumption?

I don't know about timing, but I understand that loops are somewhat slow. Assuming that x is the first column and y is the second column:

	D <- data.frame( x = 1:10, y = rnorm(10) )
	D$x[ which.min(D$y) ]

See the help of which.min for more info.

-Jarimatti mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue Jan 30 20:09:15 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 30 Jan 2007 - 10:30:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.