Make a random number generator repeatable — repeatable
v1.10.0|Source:
R/utils.R
Description
Given a function that generates random data, returns a wrapped version of that function that always uses the same seed when called. The seed to use can be passed in explicitly if desired; otherwise, a random number is used.
Arguments
- rngfunc
The function that is affected by the R session's seed.
- seed
The seed to set every time the resulting function is called.
Value
A repeatable version of the function that was passed in.
Note
When called, the returned function attempts to preserve the R session's
current seed by snapshotting and restoring
base::.Random.seed()
.