[R] inverse function of order()
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Mon Oct 4 17:39:39 CEST 2004
r[ order(o) ] will give you the answer. More generally,
x <- rnorm(100)
identical(x, x[ order(x) ][ order(order(x)) ])
[1] TRUE
On Mon, 2004-10-04 at 15:21, Wolfram Fischer wrote:
> 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?
>
> Thanks - Wolfram
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list