seed {rando}R Documentation

Random Seed Defining Functions

Description

Functions related to generating random seeds and utilising them for reproducibility.

Usage

gen_seed()

set_seed(seed)

fix_seed(reset = FALSE)

with_seed(seed, expression)

pull_seed(x)

Arguments

seed

The random seed to be used

reset

Should the fixed seed be forced to reset

expression

expression to be evaluated

x

object to extract the seed from

Details

Random values are generated based on the current seed used by the R system. This means by deliberately setting a seed in R, we can make work reproducible.

Value

gen_seed() returns a single numeric value

with_seed() returns the value of the evaluated expression after with the relevant seed as an attribute (if required)

pull_seed() returns a single numeric value

fix_seed() and set_seed() do not return anything

Functions

Examples

my_seed <- gen_seed()


set_seed(my_seed)
r_norm(n=10)
set_seed(my_seed)
r_norm(n=10)


fix_seed()
r_norm(n=3)

fix_seed()
r_norm(n=3)

fix_seed(reset=TRUE)
r_norm(n=3)


res <- with_seed(my_seed, r_norm(n = 10))
res


pull_seed(res)


[Package rando version 0.2.0 Index]