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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to