seed: Random Seed Defining Functions

Description Usage Arguments Details Value Functions Examples

Description

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

Usage

1
2
3
4
5
6
7
8
9

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)

rando documentation built on Feb. 16, 2021, 5:07 p.m.