[R] ranking a vector in R

arun smartpink111 at yahoo.com
Thu Jun 21 00:41:06 CEST 2012


Hi,

> dat<-c(5,4,3,12,15)
> rank(-dat)
[1] 3 4 5 2 1
> rank(dat)
[1] 3 2 1 4 5

A.K.



----- Original Message -----
From: Jessy <jmahachie at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Wednesday, June 20, 2012 6:24 PM
Subject: [R] ranking a vector in R

Hello,


May someone help me with how in R I can rank a vector from highest to
lowest. i.e  rank 1 (smallest rank) is given to the highest value instead
of the usual way that it get's the highest rank.

Regards,
Jessy

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list