# Same random values:
with_preserve_seed(runif(5))
with_preserve_seed(runif(5))
# Use a pseudorandom value as seed to advance the RNG and pick a different
# value for the next call:
with_seed(seed <- sample.int(.Machine$integer.max, 1L), runif(5))
with_seed(seed, runif(5))
with_seed(seed <- sample.int(.Machine$integer.max, 1L), runif(5))
Run the code above in your browser using DataLab