Skip to content
Prev 237539 / 398500 Next

same random numbers in different sessions

On 10/10/2010 4:30 AM, Liviu Andronic wrote:
The Rprofile.site is being executed before the saved workspace is 
restored.  See ?Startup for the sequence of events on startup. You could 
put the rm() in .First() in the saved workspace and it would do what you 
want.

But more generally, I would say the thing you are doing wrong is saving 
.RData sometimes, but not consistently saving it.  In my opinion it's 
safest to never save it; then you won't recover unexpected things from 
your history.  But it's also safe to always save it.  Then you'll get a 
new copy of .Random.seed saved each time.

I think the q() function makes it a little too easy to do what you did: 
  if you intend to never save it, but answer "Yes" just once, you get 
into your situation.  I don't know what the alternative should be.

One possibility would be for R to record whether the workspace was 
restored at the start of the session, and use that to determine the 
default when ending it.  But that would mess up people who are trying to 
reproduce things from identical conditions, e.g. when tracking down a bug.

Duncan Murdoch