Skip to content
Prev 262312 / 398502 Next

set.seed and for loop

That wouldn't work because the seed is for the first iteration.

Random numbers are generated by a seed, after which the seed changes
(I don't know the mechanism for changing the seed in R, but it's
static)

That means that, if you set the seed to 1001, and then run runif
function 50 times, you'll get 50 different sets of random numbers.  If
you reset the seed to 1001 and then run runif again, the result will
be the same as data[[1]], not [[23]].  And you can't just set the seed
to 1023 because that's not how the seed changes.

I think Jim's suggestion was the best.  I was thinking of that but I
couldn't remember how to extract the seed.

Sam
On Thu, Jun 9, 2011 at 12:23 PM, Samuel Le <Samuel.Le at srlglobal.com> wrote: