[R] shuffling a vector

John Fox jfox at mcmaster.ca
Mon Nov 10 18:39:00 CET 2003


Dear Rajarshi,

sample(x) will randomly permute the elements of x.

I hope that this helps,
  John

At 11:28 AM 11/10/2003 -0500, 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,
>
>-------------------------------------------------------------------
>Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
>GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
>-------------------------------------------------------------------

____________________________
John Fox
Department of Sociology
McMaster University
email: jfox at mcmaster.ca
web: http://www.socsci.mcmaster.ca/jfox




More information about the R-help mailing list