Skip to content
Prev 311456 / 398513 Next

I don't know the difference between rank and order

On 12-11-21 4:59 AM, Patrick Burns wrote:
They're not just "different", they are inverses of each other:

 > x <- rnorm(10)
 > rank(x)
  [1]  8  1  4  2  6 10  7  9  3  5
 > order(x)
  [1]  2  4  9  3 10  5  7  1  8  6
 > order(x)[rank(x)]
  [1]  1  2  3  4  5  6  7  8  9 10
 > rank(x)[order(x)]
  [1]  1  2  3  4  5  6  7  8  9 10

Duncan Murdoch