getseed: getseed generates a random number seed

View source: R/rutils.R

getseedR Documentation

getseed generates a random number seed

Description

getseed generates a seed for use within set.seed. It produces up to a 6 digit integer from the Sys.time. This Initially, at the start of a session there is no seed; a new one is created from the current time and the process ID when one is first required. Here, in getseed, we do not use the process ID so the process is not identical but this at least allows the set.seed value to be stored should the need to repeat a set of simulations arise. The process generates up to a six digit number it then randomly reorders those digits and that becomes the seed. That way, if you were to call getseed in quick succession the seeds generated should differ even when they are generated close together in time.

Usage

getseed()

Value

an integer up to 7 digits long

Examples

useseed <- getseed()
set.seed(useseed)
rnorm(5)
set.seed(12345)
rnorm(5)
set.seed(useseed)
rnorm(5)

haddonm/codeutils documentation built on April 15, 2024, 1:02 p.m.