[R] alternate rank method

Gabor Grothendieck ggrothendieck at myway.com
Sat Jun 26 17:40:14 CEST 2004


Thinking about this a bit more, the following is slightly simpler 
and should be slightly faster too:

	order(order(rev(x)),decreasing=T)[match(x,x)]


Gabor Grothendieck <ggrothendieck <at> myway.com> writes:
: 
: Here are a couple of solutions:
: 
: rx <- rank(x)
: order(-order(rev(x)))[match(rx,rx)]
: 
: rx <- rank(x)
: (2*rx-rank(x,tie="first"))[match(rx,rx)]
: 
: Douglas Grove <dgrove <at> fhcrc.org> writes:
: 
: : 
: : Hi,
: : 
: : I'm wondering if anyone can point me to a function that will
: : allow me to do a ranking that treats ties differently than
: : rank() provides for?
: : 
: : I'd like a method that will assign to the elements of each 
: : tie group the largest rank. 
: : 
: : An example:  
: : 
: : For the vector 'v', I'd like the method to return 'rv'
: : 
: :  v:  1 2 3 3 3 4 5 5 6 7
: : rv:  1 2 5 5 5 6 8 8 9 10
: : 
: : 
: : Thanks,
: : Doug Grove




More information about the R-help mailing list