[R] inverse function of order()

Gabor Grothendieck ggrothendieck at myway.com
Mon Oct 4 17:49:19 CEST 2004


Wolfram Fischer <wolfram <at> fischer-zim.ch> writes:
> I have:
>  d <- sample(10:100, 9)
>  o <- order(d)
>  r <- d[o]
> How I can get d (in the original order), knowing only r and o?


When order acts on a permutation of 1:n it is an involution, i.e.
it is its own inverse, therefore:

r[order(o)]




More information about the R-help mailing list