问题
In the olympics, if two people are tied for silver - they don't give out a bronze medal.
Here's a sample of the kind of data I'm working with:
x <- c(0.64, 0.64, 0.63, 0.62, 0.62, 0.62, 0.61, 0.6, 0.6, 0.58)
I'd like to create a ranking function that outputs like so:
rank.fun(x)
1 1 3 4 4 4 7 8 8 10
I've tried messing around with findInterval, rank, floor, ceiling but none of them seem to provide the result I'm looking for.
回答1:
How about this:
rank(-x, ties.method="min")
回答2:
It looks like you can do this with rank:
> rank(-x, ties="min")
[1] 1 1 3 4 4 4 7 8 8 10
来源:https://stackoverflow.com/questions/9071143/extending-rank-olympic-style