On Mon, 2003-11-10 at 10:28, Rajarshi Guha wrote:
> Hi,
>   I'me trying to write  a function that will shuffle a vector. At the
> moment I'm baically making a vector of randomized indices and then
> making  a new vector from the original one using these random indices.
> 
> However, is there an alternative (more elegant) method to do this? I
> tried help.search('shuffle') but it does'nt return anything relevant.
> 
> Thanks,


You might want to look at the permute() function in the 'gregmisc'
package.

Example:

> x <- 1:10
> permute(x)
 [1]  1  3  2  6  5  7 10  8  9  4

HTH,

Marc Schwartz

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to