[R] shuffling a vector
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Nov 10 17:50:45 CET 2003
Rajarshi Guha <rxg218 at psu.edu> writes:
> 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.
sample(x,length(x))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list