[R] save.image() excluding functions

Huntsinger, Reid reid_huntsinger at merck.com
Fri Feb 22 19:00:43 CET 2002


I have been thinking about using CVS with R for a few reasons, partly to
make it easy for a group to work together on common R things but not get in
each other's way, and partly to be able to keep doing things the easy way
(define functions in R cmd window, use fix to edit them, rely on .RData to
keep my stuff...). 

My idea was to implement a few R functions which would 1) set up a CVS
working directory for a project, 2) set up link via save()s and load()s
(ascii) to/from the CVS working directory, and 3) issue CVS commands.
Because I'm mostly interested in functions, it seemed like it might be a
good idea to implement save() + CVS "add" as a callback from the function()
function (unless user turns this off...). 

One benefit of a scheme like this would be that you could keep other related
code (C, Fortran, etc) here as well.

Might something like this meet the needs expressed in your post, Dr. Lobo?
Anyone know of something like this already? Any suggestions or advice? 

Reid Huntsinger


-----Original Message-----
From: Thomas Lumley [mailto:tlumley at u.washington.edu]
Sent: Friday, February 22, 2002 12:07 PM
To: Agustin Lobo
Cc: r-help
Subject: Re: [R] save.image() excluding functions


On Fri, 22 Feb 2002, Agustin Lobo wrote:
>
> If the recommendation is to write functions with an external editor
> (I mean, avoiding fix()), keep them as text files (*.R) and using
> source() to bring them into the R session, why not excluding,
> by default, function objects from save.image() ?
> In particular, from the final save.image(),
> the one that is proposed at q().
>
> In this way, functions would not get included within .RData,


There's a number of problems with excluding functions from .RData.
Primarily

1/ compatibility. The S languages have never distinguished between
functions and other forms of data in this way.

2/ Functions cannot necessarily be stored as text. They have
environments, which could in principle reference any amount of data. The
only completely reliable way for R to store a function is using save().
You as the author of a function can know that the environment is
irrelevant but it's quite hard for R to know this (Luke Tierney's
proposed byte-code compiler needs to be able to tell, so this may change)


In fact the most common recommendation is not just that functions should
be defined in external files but that everything else should be as well.
>From that viewpoint .RData is just a convenient scratchpad to store
intermediate results without having to re-run them, and it really has to
contain the entire state of the program.

Anyone who really wants to modify save.image() in their own copy of R can
do so, but I think it's unlikely that this change would be popular as a
default.


	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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