Learn R Programming

harvestr (version 0.1)

withpseed: 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

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

  withseed(seed, expr, envir = parent.frame())

  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.
delete
logical to delete if seed is null.

Value

  • the .Random.seed if defined, otherwise NULL a valid .Random.seed value.

Details

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