Returns the dense ranks of the values in a vector.
DenseRank gives the ranking within the vector x, but the ranks are consecutive. No ranks are skipped if there are ranks with multiple items. (Unlike
rank gives the ranking within the vector x too, but ties are assigned the same rank, with the next ranking(s) skipped.)
DenseRank(x, na.last = TRUE)
- a numeric, complex, character or logical vector.
- for controlling the treatment of
TRUE, missing values in the data are put last; if
FALSE, they are put first; if
NA, they are removed; if
"keep"they are kept with rank
na.last = NA, when missing values are removed). The vector is of integer type unless x is a long vector.
(r1 <- rank(x1 <- c(3, 1, 4, 15, 92))) x2 <- c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5) names(x2) <- letters[1:11] (r2 <- rank(x2)) # ties are averaged (r2 <- DenseRank(x2)) # ranks are enumerated