Try this:

# for the minimum
a$price[which.min(a$n)]

# for the maximum
a$price[which.max(a$n)]

On Thu, Mar 19, 2009 at 10:15 AM, tedzzx <zengzhenxing@gmail.com> wrote:

>
> Dear R experts,
>
> How to find out the index of minimum or maxmum number in a vetor or
> data.frame?
>
> For example,
>
> a=
>
> n   price
> 1     50
> -2    100
> 0    200
> -1   300
> ......
>
>
> I want to find out the row which the n is the smallest or largestest and
> extract the price.
>
>
> Thanks
>
> Ted
> --
> View this message in context:
> http://www.nabble.com/find-the-index-of-the-smallest-or-biggest-number-in-a-vetor-or-data.frame-tp22599905p22599905.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


