[R] is auto-save possible?

Duncan Temple Lang duncan at research.bell-labs.com
Wed Dec 5 01:25:03 CET 2001


The question of performing auto-saves every n commands goes back
several weeks, but hopefully the delay in responding is worthwhile.
The upcoming version 1.4.0 of R has a facility (addTaskCallback()q) by
which one can register a collection of functions that are invoked at
the end of each (successful) top-level expression.  This can be used
perform auto-saves, and other things such as updating GUI displays,
commiting changes to databases (i.e. transactions), validation of
objects, etc. One can even examine the expression that was just
evaluated and check if it was an assignment, or if it changed an important
variable that should be saved.

 There is a description of the mechanism at
  http://developer.r-project.org/TaskHandlers.pdf

Unlike other suggestions, I think doing auto-saves on the basis of
time is not the ideal approach. As others have pointed out, it relies
on the nature of the event loop which is neither portable or likely to
remain exactly the same.  After 1.4.0 is released, I plan to add
timers and readers/callbacks for connections and that will give
different features and also characteristics.

I hope the addTaskCallback() does what you want. 
 D.


Liaw, Andy wrote:
> Dear R-help,
> 
> This is just a wishlist item:  Is it possible at all to make R (optionally)
> automagically do save.image() periodically (e.g., every fixed number of
> commands or >= fixed amount of time)?  
> 
> The reason I asked is that I frequently run R-1.3.1 inside XEmacs 21.4.5/ESS
> 5.1.19 under WinNT, and had seen Rterm.exe crashed a few times for no
> apparent reason (and not reproducible).  When that happens, I lost all the
> objects created in that R session and had to re-run the script (which could
> be time consuming).  At one time R crashed right in the middle of quitting,
> which corrupted the .Rdata file.  Luckily I had a backup that was fairly
> recent that I didn't loose everything.  (Admittedly, auto-save wouldn't help
> this last problem though.)
> 
> Cheers,
> Andy
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
_______________________________________________________________

Duncan Temple Lang                duncan at research.bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-3217
700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
Murray Hill, NJ  07974-2070       
         http://cm.bell-labs.com/stat/duncan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list