[R] rank in descending order?

Damián Cirelli damian.cirelli at maine.edu
Wed Dec 1 23:26:26 CET 2004


Try this:

r <- sort(rank(a, ties.method="average"), decreasing=T)


Jose Quesada wrote:

>Hi,
>
>Is there any simple solution to get ranks in descending order?
>Example, 
>a <- c(10, 98, 98, 98, 99, 100)
>r <- rank(a, ties.method="average")
>
>produces
>1 3 3 3 5 6
>
>I would want this instead:
>6 5 3 3 3 1
>
>Note that reversing r doesn't work but in small examples.
>
>Thanks,
>-Jose
>
>  
>




More information about the R-help mailing list