[R] Restoring .Random.seed

Talbot Katz topkatz at msn.com
Thu May 31 20:15:04 CEST 2007


Suppose I have a function which does some random number generation within.  
The random number generation inside the function changes the value of 
.Random.seed in the calling environment.  If I want to restore the 
pre-function call .Random.seed, I can do:


Is there a way to do the restoration inside the function?  I tried putting 
the "save.seed<-.Random.seed" and ".Random.seed<-save.seed" statements 
inside the function, but that didn't work.  Perhaps there's some clever way 
to use environment() functions?  (I confess I still haven't grasped those 
very well.)  Also, the help section on .Random.seed mentions that some of 
the random number generators save their state differently.  Does each random 
generation method have a way to restore its state?


--  TMK  --
212-460-5430	home
917-656-5351	cell

More information about the R-help mailing list