Skip to content
Prev 270108 / 398502 Next

Function rank() for data frames (or multiple vectors)?

On Aug 29, 2011, at 15:39 , Sebastian Bauer wrote:

            
Yes, order() and rank() are different beasts so you'd need the presort.

You might consider this:
a b
1 1 2
2 1 2
3 1 1
4 2 3
5 2 1
[1] 2 2 2 5 4
[1] 2.5 2.5 1.0 5.0 4.0

Figuring out why order(order(x)) == rank(x) if you ignore ties is "left as an exercise" (i.e., I can't recall the argument just now...).