Compute ranks

xrank(x, best = TRUE, na.rm = FALSE)

Arguments

x

vector of values to be ranked

best

logical; if TRUE (default), the rank of the j-th element is defined as the number of other elements strictly larger than the j-th. Otherwise, the rank is defined as the number of other elements strictly smaller than the j-th.

na.rm

logical; if TRUE, then NA's are removed from x (if any).

Value

vector of the same dimension as x containing the ranks

Examples

xrank(c(4,4,4,3,1,10,7,7))
#> [1] 4 4 4 7 8 1 2 2