This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/rank.html
rank {base}R Documentation

Sample Ranks

Description

Returns the sample ranks of the values in a numeric vector. Ties result in ranks being averaged.

Usage

rank(x, na.last = TRUE)

Arguments

x

a numeric vector.

na.last

for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed.

See Also

order and sort.

Examples

(r1 <- rank(x1 <- c(3,1,4,59,26)))
(r2 <- rank(x2 <- c(3,1,4,5,9,2,6,5,3,5))) # ties

## rank() is "idempotent": rank(rank(x)) == rank(x) :
stopifnot(rank(r1) == r1, rank(r2) == r2)

[Package base version 1.5.0 ]