[R] Create checkpoint - was: How to de-source and re-source a file?

Rainer M Krug r.m.krug at gmail.com
Thu Dec 8 09:57:43 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/12/11 21:27, Roebuck,Paul L wrote:
> So create a checkpoint...
> 
> 
> -----------------------------myfile.R---------------------------------
>
> 
checkpoint.file <- "checkpoint_appname.RData"
> if (!file.exists(checkpoint.file) { ## Do compute intensive
> processing... { my.seed <- 1234 ans <- long.comp( my.seed) } 
> objects2save <- c("ans", "my.seed") save(list=objects2save, 
> file=checkpoint.file) } else { load(checkpoint.file) } browser() 
> ...
> 
> -----------------------------------------------------------------------

Nice
> 
idea - like it. I am going to use it in my next simulation. As
the simulation is starting from a vanilla R session, I am going to use
save.image() to save the complete workspace.

Am I right in assuming, that everything in my workspace gets saved,
and if I want to start off from this checkpoint, I have to

1) load all packages again
2) load() the workspace as saved by save.image()
3) and voilá, I can continue?

Or is there anything which will *not* be restored with an approach
like this (assuming a S3 and S4 classes etc.)?

Cheers,

Rainer

> 
> 
> On 12/6/11 12:44 PM, "Michael" <comtech.usa at gmail.com> wrote:
> 
>> the problem with restarting R is that I then have to re-execute
>> the program until the point where I wanted to debug, which is a
>> very long-waiting time...
>> 
>> On Tue, Dec 6, 2011 at 12:17 PM, Duncan Murdoch 
>> <murdoch.duncan at gmail.com>wrote:
>> 
>>> On 06/12/2011 1:10 PM, Michael wrote:
>>> 
>>>> i.e. how to make sure the function that was loaded into
>>>> workspace/memory is the version that I edited latest... not
>>>> some stale version...
>>>> 
>>>> This might solve some of my breakpoint and browser/debug
>>>> problem, even the RStudio problem that I've met....
>>>> 
>>> 
>>> You can use rm() to remove a function.
>>> 
>>> You can also quit and restart R, making sure that it *does not*
>>> load an existing workspace (by deleting the .Rdata file if it
>>> exists, and never answering "yes" to the question to save it.)
>>> This gives you a nice clean slate.
>>> 
>>> Duncan Murdoch
>>> 
>> 
>> [[alternative HTML version deleted]]
>> 
>> ______________________________________________ 
>> R-help at r-project.org mailing list 
>> 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.
> 
> ______________________________________________ R-help at r-project.org
> mailing list 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.


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer at krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7gfAcACgkQoYgNqgF2egqDiwCcDlZrtLf9xRhsKx7N41y0fD7q
E4EAnj0WO9lWCfyshTmIBYGYeH31TgCp
=oJNS
-----END PGP SIGNATURE-----



More information about the R-help mailing list