[R] swap

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Fri Aug 22 11:59:37 CEST 2008


> I wonder if there is any swap function in R that does the following:
> x <- seq(1,10,12)

This just makes x equal to 1.  I'm guessing you meant something like
x <- 1:10

> x1 <- swap(x)
> x1 
> 1 8 3 4 5 6 7 2 10

It's not terribly clear what you want swap to do.  You can reorder the 
elements of x using sample, e.g.
sample(x)
[1]  6 10  8  4  2  5  1  9  3  7

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list