Ranking with ties

Hi there, i have to rank high values in a column of a data frame like this:

example <- data.frame(

If i would rank the values with

example$rank<- rank(-example$value)

I would have something like this:

[1] 7.5 7.5 6.0 5.0 4.0 3.0 2.0 1.0

When actually i am looking something like this:

[1] 7 8 6 5 4 3 2 1

If they are tied, i dont mind wich one has a higher rank.

Thank you!

Check the ties.method argument of base::rank function.

You can consider using ties.method = "random".

1 Like

Thank you!

That totally did it, thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.