[R] inverse function of order()

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 4 17:06:10 CEST 2004


On Mon, 4 Oct 2004, 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?

d <- r
d[o] <- r

It's a simple inverse, as your subject suggests.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list