[R] Easy way to get top 2 items from vector

Noah Silverman noah at smartmediacorp.com
Fri Sep 4 01:17:59 CEST 2009


Hi,

I use the max function often to find the top value from a matrix or 
column of a data.frame.

Now I'm looking to find the top 2 (or three) values from my data.

I know that I could sort the list and then access the first two items, 
but that seems like the "long way".  Is there some way to access "max_2" 
or similar?


Thanks!

--
Noah




More information about the R-help mailing list