When the parallel package is used, setting the RNG seed for reproducibility
involves more than simply calling set.seed()
. set.rseed
takes
care of the additional overhead.
set.rseed(seed)
seed for the random number generator
If the parallel
package is not on the search path, then set.seed()
is called.
If parallel
is on the search path, then the RNG kind is set to "L'Ecuyer-CMRG"
,
the seed is set and mc.reset.stream
is called.
# These should give identical results, even if the `parallel' package is loaded.
set.rseed(123); do(3) * resample(1:10, 2)
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> V1 V2
#> 1 5 6
#> 2 5 4
#> 3 4 7
set.rseed(123); do(3) * resample(1:10, 2)
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> V1 V2
#> 1 5 6
#> 2 5 4
#> 3 4 7