I’m trying to understand how the order() function works. I was under the impression that it returned a permutation of indices, which when sorted, would sort the original vector.
For instance,
> a <- c(45,50,10,96)
> order(a)
[1] 3 1 2 4
I would have expected this to return c(2, 3, 1, 4), since the list sorted would be 10 45 50 96.
Can someone help me understand the return value of this function?
This seems to explain it.
I’ll bet you’re thinking of rank.