random_seed | R Documentation |
Get, set and restore the state of the random number generator state.
get_random_seed()
set_random_seed(seed)
restore_random_seed(seed)
seed |
( |
These functions originate from the withr
package.
get_random_seed()
returns a list with two components random_seed
and rng_kind
or NULL if no seed was set; set_random_seed()
and restore_random_seed()
do not return anything.
old_seed <- get_random_seed()
on.exit(restore_random_seed(old_seed))
set_random_seed(42)
value1 <- runif(1)
set_random_seed(42)
value2 <- runif(1)
stopifnot(all.equal(value1,value2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.