doRNGversion(x)
NULL
to
reset to the default behaviour, i.e. of the latest
version.a character string If x
is missing this function
returns the version number from the current behaviour. If
x
is specified, the function returns the old value
of the version number (invisible).
Sets the behaviour of %dorng% foreach loops from a given version number.
doRNGseed
,
and therefore of %dorng%
loops, changed in the
case where the current RNG was L'Ecuyer-CMRG. Using
set.seed
before a non-seeded loop used not to be
identical to seeding via .options.RNG
. Another bug
was that non-seeded loops would share most of their RNG
seed! ## Seeding when current RNG is L'Ecuyer-CMRGRNGkind("L'Ecuyer")doRNGversion("1.4")# in version >= 1.4 seeding behaviour changed to fix a bugset.seed(123)res <- foreach(i=1:3) %dorng% runif(1)Error in summary.connection(connection): invalid connectionres2 <- foreach(i=1:3) %dorng% runif(1)Error in summary.connection(connection): invalid connectionstopifnot( !identical(attr(res, 'rng')[2:3], attr(res2, 'rng')[1:2]) )Error in identical(attr(res, "rng")[2:3], attr(res2, "rng")[1:2]): object 'res' not foundres3 <- foreach(i=1:3, .options.RNG=123) %dorng% runif(1)Error in summary.connection(connection): invalid connectionstopifnot( identical(res, res3) )Error in identical(res, res3): object 'res' not found# buggy behaviour in version < 1.4doRNGversion("1.3")res <- foreach(i=1:3) %dorng% runif(1)Error in summary.connection(connection): invalid connectionres2 <- foreach(i=1:3) %dorng% runif(1)Error in summary.connection(connection): invalid connectionstopifnot( identical(attr(res, 'rng')[2:3], attr(res2, 'rng')[1:2]) )Error in identical(attr(res, "rng")[2:3], attr(res2, "rng")[1:2]): object 'res' not foundres3 <- foreach(i=1:3, .options.RNG=123) %dorng% runif(1)Error in summary.connection(connection): invalid connectionstopifnot( !identical(res, res3) )Error in identical(res, res3): object 'res' not found# restore default RNGRNGkind("default")# restore to current doRNG versiondoRNGversion(NULL)