[R] Rank - Descending order
    Gabor Grothendieck 
    ggrothendieck at myway.com
       
    Tue Apr 20 07:08:40 CEST 2004
    
    
  
Here are a couple to try:
z <- c(1,5,2,4)
rank(-rank(z))
# If z is numeric this can be simplified to:
rank(-z)
I haven't checked what happens to NAs and ties.method.
Manoj - Hachibushu Capital <Wanzare <at> HCJP.com> writes:
: 
: Dear All,
: 	Is there any simple way to way to produce "rank", for a given
: list, but in a descending order?
: 
: 	E.G: 	
: 		x	= list(a=c(1,5,2,4));
: 		rank(x$a);	produces 1,4,2,3 
: 
: 	However I am looking for a way to generate (4,1,3,2). 
: 
: 	It would be particularly nice if the proposed solution has all
: the niceties of rank function (like NA handling and ties.method
: functionality) 
: 
: TIA
: 
: Manoj
    
    
More information about the R-help
mailing list