Ranks of Data

DESCRIPTION:
Returns a vector of the ranks of the input.

USAGE:
rank(x, na.last = T)

REQUIRED ARGUMENTS:
x:
numeric vector.
Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:
na.last:
vector with one element. If na.last=TRUE, missing values are put last; if FALSE, they are put first. If na.last=NA, missing values are deleted. An error is given if na.last is of mode "character" and missing values occur in x.

VALUE:
the ranks; i.e., the ith value is the rank of x[i]. In case of ties, the average rank is returned.

DETAILS:
The treatment of missing values is controlled by na.last.

For the rank of a matrix see svd, qr or chol.


WARNING:
If na.last=NA, the ith value of the result corresponds to the ith element of the vector that is the result of removing NAs from x.

SEE ALSO:
cor , order , quantile , sort , testscores .

EXAMPLES:
# create sample objects
diffgeom <- testscores[,1]
complex <- testscores[,2]

rank(diffgeom, na.last="") # cause error if missing values are present

# Spearman's rank correlation between two sets of testscores cor(rank(diffgeom), rank(complex))