I'd like to rank the vector, x in descending order and find the presence of ties.
x <- c(0, 0, 1, 0, 1, 0, 2, 0)
When I rank() these I get:
> rank(desc(x))
[1] 6.0 6.0 2.5 6.0 2.5 6.0 1.0 6.0
- The value of 2 gets a 1.0 rank. That makes sense to me.
- The two values of 1 get a 2.5 rank. That makes sense, too, as the fractional part of the return value signals a tie.
- The five values of 0 get a 6.0 rank. This confuses me. Both because
rank()'s default ties.method is "average" and 6 isn't that, but mostly I'm confused that I get no indication of a tie, despite the five zeros in the vector.
Perhaps I'm going about this all wrong. My ideal output is achieved by rank(x, ties.method = "min") but I also need to know whether ties exist.
Thanks in advance for any guidance.