RNG version
Change the RNG version and restore it afterwards.
with_rng_version(version, code) local_rng_version(version, .local_envir = parent.frame())
version |
|
code |
|
.local_envir |
The environment to apply the change to. |
with_rng_version()
runs the code with the specified RNG version and
resets it afterwards.
local_rng_version()
changes the RNG version for the caller
execution environment.
[any]
The results of the evaluation of the code
argument.
withr
for examples
RNGkind() with_rng_version("3.0.0", RNGkind()) with_rng_version("1.6.0", RNGkind()) with_rng_version("3.0.0", with_seed(42, sample(1:100, 3))) with_rng_version("1.6.0", with_seed(42, sample(1:100, 3))) RNGkind() fun1 <- function() { local_rng_version("3.0.0") with_seed(42, sample(1:100, 3)) } fun2 <- function() { local_rng_version("1.6.0") with_seed(42, sample(1:100, 3)) } RNGkind() fun1() fun2() RNGkind()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.