Re: [R] Fast way of finding top-n values of a long vector

2009-06-04 Thread Allan Engelhardt
Greg Snow wrote: Try adding a version that uses sort with the partial argument, that should be faster than regular sort (for long enough test vectors) and possibly faster than the max solutions when finding more than just the largest 2. I find the documentation for the partial argument in sor

Re: [R] Fast way of finding top-n values of a long vector

2009-06-04 Thread Greg Snow
Try adding a version that uses sort with the partial argument, that should be faster than regular sort (for long enough test vectors) and possibly faster than the max solutions when finding more than just the largest 2. Also, for your max solutions, what happens when the 2 largest values are id

Re: [R] Fast way of finding top-n values of a long vector

2009-06-04 Thread Barry Rowlingson
On Thu, Jun 4, 2009 at 9:18 AM, Allan Engelhardt wrote: > I want to apply this code to a few tens of thousands of vectors so speed > does matter.  In C or similar I would of course calculate the result with a > single pass through x, and not with three passes as in 'max2'. > So why not code it