[R] runif and sample with reproducibility

Philippe Glaziou glaziou at pasteur-kh.org
Mon Dec 22 11:23:58 CET 2003


Eric ESPOSITO <eric.esposito at gazdefrance.com> wrote:
> I would like to sample a population but the result needs to be
> reproducible, using 'runif' or 'sample' is the good way to do it but I
> can't manage to make the results reproducible even with the 'set.seed'
> function.
> My aim is that th call to 'sample(1:100,10)' gives always the same result,
> how can I do that?



Can you give an example of set.seed not giving reproducible samples?

set.seed(101)
sample(1:100,10)
 [1] 38  5 70 64 24 29 55 32 58 50
set.seed(101)
sample(1:100,10)
 [1] 38  5 70 64 24 29 55 32 58 50

-- 
Philippe Glaziou
Epidemiologist




More information about the R-help mailing list