Sets the uniform and normal random number generators and the seed.
The old setting is returned using invisible()
in a format
which can be used in another call to setRNG
. (This would reset to the
original value.) If no arguments are given the current setting is returned,
not using invisible()
. In R see RNGkind
for more details.
Note that in a function using setRNG
it is good practice to
assign the old setting to a variable, then reset to the old value on exiting
the function (using on.exit
). This avoids the possibility that
overall RNG behaviour in a session, other than within your function, may be
disrupted by your function.