From ggrothendieck at myway.com  Wed Jul 21 18:08:19 2004
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Wed Jul 21 18:09:23 2004
Subject: [Rd] rank() with decreasing argument - feature request
References: <1090422417.3012.26.camel@localhost.localdomain>
Message-ID: <loom.20040721T180340-170@post.gmane.org>

Adaikalavan Ramasamy <ramasamy <at> cancer.org.uk> writes:

> 
> I like to request that the an argument/option to rank numbers in
> decreasing order, i.e. largest number first, be added to rank().
> Currently I am using the following construct, which can get a bit
> cumbersome at time.
> 
> > rank.decreasing <- function(x) length(x) + 1 - rank(x)
> > x <- c(101, 103, 102)
> > rank(x)
> [1] 1 3 2
> > rank.decreasing(x)
> [1] 3 1 2


If your data is numeric then 

   rank(-x)

would be a bit shorter.  I agree, however, that it would be nice to support 

   decreasing = TRUE 

as an arg to rank, not only for the above reason but also for consistency 
with order which already supports such an argument.


[Rd] rank() with decreasing argument - feature request
Gabor Grothendieck