On 04/07/2019 12:32 p.m., Spencer Brackett wrote:
Hello again,

   I might be repeating myself here, so my apologies, but do I have to run a
script file from my R Studio to reimplement my previous work for a given
project.... so to start up where I left off.... or is opening up R and,
with my global environment automatically reloading as it was when I last
worked on, sufficient?


Saving your workspace when you quit is a common default, but it is generally a bad idea. Old junk collects in there, and makes new results harder to debug.

A better workflow is to never save the whole workspace. If you have just computed some object(s) and the computation took so long you don't want to repeat it, then save just a minimum, and load them later in a new session.

A particularly dangerous situation happens if you sometimes save your workspace and sometimes don't. You can end up with situations like this:

Session 1: compute some random values. Save the workspace, including the random number key.

Session 2: automatically load the saved workspace. Compute some new random values. Quit without saving the workspace.

Session 3: automatically load the saved workspace from Session 1, including the random number seed. Any random values computed in this session could be identical to the values in Session 2, because they are starting with the same seed.

If you don't have a saved workspace to load, you end up with a blank slate, and the random number key is generated based on time of day and process number, so is almost certainly different in every session. (Sometimes you want a repeated seed for reproducibility, but it's always bad when you're surprised by one.)

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to