Learn R Programming

nprcgenekeepr (version 3.0.0)

set_seed: Set a reproducible RNG seed across R versions

Description

R 3.6 changed how set.seed and sample work. For R 3.6 and later this function calls set.seed(seed, sample.kind = "Rounding"), which restores the earlier sample() behavior, so results of sample() differ from those after a plain set.seed(seed). For earlier versions of R it calls set.seed(seed). This lets unit tests give the same results on multiple versions of R in a CICD test build. Messages and warnings from set.seed are suppressed.

Usage

set_seed(seed = 1L)

Value

NULL, invisibly.

Arguments

seed

argument to set.seed

Examples

Run this code
set_seed(1)
rnorm(5)

Run the code above in your browser using DataLab