Aliases: with_seed local_seed with_preserve_seed local_preserve_seed
Keywords:
### ** Examples # Same random values: with_preserve_seed(runif(5))
[1] 0.4726363 0.5059356 0.9119592 0.5682818 0.3840498
with_preserve_seed(runif(5))
[1] 0.09286475 0.25531274 0.19759133 0.14706001 0.73993505
# Use a pseudorandom value as seed to advance the RNG and pick a different # value for the next call: with_seed(seed <- sample.int(.Machine$integer.max, 1L), runif(5))
[1] 0.8557672 0.7798454 0.2096122 0.4362620 0.4543115
with_seed(seed, runif(5))
[1] 0.8557672 0.7798454 0.2096122 0.4362620 0.4543115
with_seed(seed <- sample.int(.Machine$integer.max, 1L), runif(5))
[1] 0.87131469 0.50131177 0.02109098 0.73380994 0.76948811