Learn R Programming

Capsule (version 0.2.0)

set_seed: Set and Track Random Seed

Description

Set a random seed and track it for reproducibility. Note: This function is explicitly designed to set random seeds as requested by the user.

Usage

set_seed(
  seed = NULL,
  kind = NULL,
  normal.kind = NULL,
  sample.kind = NULL,
  analysis_name = NULL,
  registry_file,
  set_seed = TRUE
)

Value

The seed value (invisibly)

Arguments

seed

Numeric. Random seed to set. If NULL, generates random seed.

kind

Character. RNG kind (see ?set.seed). Default NULL uses current.

normal.kind

Character. Normal RNG kind. Default NULL uses current.

sample.kind

Character. Sample RNG kind. Default NULL uses current.

analysis_name

Character. Name to associate with this seed

registry_file

Character. Path to seed registry (required).

set_seed

Logical. If TRUE, actually sets the seed. If FALSE, only tracks it. Default TRUE.

Examples

Run this code
if (FALSE) {
# Set and track a specific seed
set_seed(12345, analysis_name = "simulation_1",
         registry_file = tempfile(fileext = ".json"))

# Generate and track a random seed
set_seed(analysis_name = "bootstrap_analysis",
         registry_file = tempfile(fileext = ".json"))
}

Run the code above in your browser using DataLab