next up previous
Next: Stopping on a warning Up: R, S, and Splus Previous: Unfreezing R

Resetting the seed

Suppose you've executed a number of commands and want to save the seed so that you can pick up again at the same point in the random number generator as you left off. This can be handy for debugging. The following will save and restore your seed:

>save.seed=.Random.seed

>out1=rnorm(1)

# a bunch of commands

>.Random.seed=save.seed

>out2=rnorm(1)

# out1 and out2 should be the same



Chris Paciorek 2012-01-21