with_seed: With Seed Evaluation

View source: R/seed.R

with_seedR Documentation

With Seed Evaluation

Description

Evaluates expression with a seed and resets to initial seed state on exit

Usage

with_seed(
  expr,
  seed = NA_integer_,
  kind = NULL,
  normal.kind = NULL,
  sample.kind = NULL
)

Arguments

expr

expression to evaluate.

seed

a single value, interpreted as an integer, or NULL, with the exception that NA can be provided to prevent passing 'seed' argument. Default is NA_integer_.

kind

character or NULL. If kind is a character string, set R's RNG to the kind desired. Use "default" to return to the R default.

normal.kind

character string or NULL. If it is a character string, set the method of Normal generation. Use "default" to return to the R default. NULL makes no change.

sample.kind

character string or NULL. If it is a character string, set the method of discrete uniform generation (used in sample, for instance). Use "default" to return to the R default. NULL makes no change. Only applies on R version >= 3.6.0.

Details

see ‘Details’, from set.seed, with the exception of 'seed'. Using seed = NA_integer_, NOTHING will be passed to set.seed nor RNGkind and NOTHING will be restored once done. Otherwise, set.seed will be used and once done RNGkind will be restored and ".Random.seed" from globalenv set back to its initial value (included removed if it did not exist).


IFC documentation built on Sept. 14, 2023, 1:08 a.m.