Skip to content
Prev 33065 / 398506 Next

Ordering long vectors

I need to order a long vector of integers with rather few unique values.
This is very slow:
[1] 189.18   0.09 190.48   0.00   0.00

But with no ties
[1] 1.18 0.00 1.18 0.00 0.00

it is very fast!
This gave me the following idea: Since I don't care about keeping the 
order within tied values, why not add some small disturbance to  x,
and indeed,
[1] 1.66 0.00 1.66 0.00 0.00
[1] TRUE

it works! 

Is there an obvious (=better) solution to this problem that I have 
overlooked? In any case, I think that the problem with order and many 
ties is worth mentioning in the help page. 

For the record: R-1.7.0, RH9

G?ran
---
 G?ran Brostr?m                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Ume? University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Ume?, Sweden             e-mail: gb at stat.umu.se