Learn R Programming

harvestr (version 0.3)

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())

  get.seed()

  replace.seed(seed, delete = TRUE)

  GetOrSetSeed()

  withpseed(seed, expr, envir = parent.frame(),
    cache = FALSE)

Arguments

seed
a valid seed value
expr
expression to evaluate.
envir
the environment to evaluate the code in.
delete
logical to delete if seed is null.
cache
use cache, see Caching in harvestr

Value

  • the .Random.seed if defined, otherwise NULL a 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. withpseed is the same as withseed, but assumes a parallel seed from spawn.sprng. When evaluated the beginning and endind seeds are saved in the attributes "starting.seed" and "ending.seed", for continued evaluation with harvest

See Also

set.seed