Learn R Programming

harvestr (version 0.7.1)

withseed: Do a computation with a given seed.

Description

Do a computation with a given seed.

safe version of retrieving the .Random.seed

Get or Set Current Seed - Safe Version

Usage

withseed(seed, expr, envir = parent.frame(), cache = getOption("harvestr.use.cache", defaults$cache()), cache.dir = getOption("harvestr.cache.dir", defaults$cache.dir()), time = getOption("harvestr.time", defaults$time()))
get.seed()
replace.seed(seed, delete = TRUE)
GetOrSetSeed()

Arguments

seed
a valid seed value
expr
expression to evaluate.
envir
the environment to evaluate the code in.
cache
should results be cached or retrieved from cache.
cache.dir
Where should cached results be saved to/retrieve from.
time
should results be timed?
delete
logical to delete if seed is null.

Value

the .Random.seed if defined, otherwise NULLa valid .Random.seed value.

Details

Compute the expr with the given seed, replacing the global seed after compuatations are finished.

does not replace the global .Random.seed

Replaces the .Random.seed with seed unless seed is null, then it will delete the .Random.seed if delete=T

Always returns a valid seed. Useful for grabbing a seed used to generate a random object.

See Also

set.seed