[R] Reloading old R Environments/Workspaces
Spencer Brackett
@pbr@ckett20 @end|ng |rom @@|ntjo@ephh@@com
Thu Jul 4 20:34:53 CEST 2019
Thank you for the clarification. So should I not rely on importing a saved
environment from now on? I am currently experiencing some difficulties with
reproducing the output (aka the objects listed in my environment), which is
why I was trying to load them all at once.
Best,
Spencer
On Thu, Jul 4, 2019 at 1:24 PM Duncan Murdoch <murdoch.duncan using gmail.com>
wrote:
> 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
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list