[R] Rank - Descending order
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Apr 20 08:34:22 CEST 2004
rank((-x$a))
rank() does not work on lists but on numeric vectors, and the above works
generally for numeric vectors.
On Tue, 20 Apr 2004, Manoj - Hachibushu Capital wrote:
> 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)
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list