set.randomseed: Set seed with a random value using Sys.time()

View source: R/helpers.R

set.randomseedR Documentation

Set seed with a random value using Sys.time()

Description

This will set a random seed.

Usage

set.randomseed(set.seed = TRUE)

Arguments

set.seed

Logical. If TRUE, the default, then the function will call set.seed internally with the new random seed.

Details

This function uses 6 decimal places of Sys.time(), i.e., microseconds. Due to integer limits, it also truncates at 1000 seconds, so there is a possibility that this will be non-unique after 1000 seconds (at the microsecond level). In tests, this showed no duplicates after 1e7 draws in a loop, as expected.

Value

This will return the new seed invisibly. However, this is also called for its side effects, which is a new seed set using set.seed

Note

This function does not appear to be as reliable on R <= 4.1.3


reproducible documentation built on Nov. 22, 2023, 9:06 a.m.