When there are ties in the original data, is there a way to create a ranking without gaps in the ranks (consecutive, integer rank values)? Suppose:
x <- c(10, 10, 10, 5, 5, 20, 20)
rank(x)
# [1] 4.0 4.0 4.0 1.5 1.5 6.5 6.5
In this case the desired result would be:
my_rank(x)
[1] 2 2 2 1 1 3 3
I've played with all the options for ties.method
option (average
, max
, min
, random
), none of which are designed to provide the desired result.
Is it possible to acheive this with the rank()
function?