i'm not sure if this is what you had in mind, but you can sample the vector
indices.
samp <- sample(1:800000, size=800000, replace=F)
new.vec <- vec[samp]
you can then do this a bunch of times via a for loop or an apply function.
On Mon, Apr 6, 2009 at 10:52 PM, Diane Kuhn <dmkuhn at fas.harvard.edu> wrote:
Hi all, I'm interested in randomly reassigning the order of elements in a
vector and need to do this repetitively over a large number of observations.
Has anyone done something similar already and have a suggestion on an
efficient way to approach this? I realize that you could write a for loop
that basically samples from the vector elements, and then removes the
element selected on each iteration, but we have about 800,000 observations
in our data, so I'm hoping to use a quicker method.
Thanks,
Diane
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam