Skip to content

save.image() excluding functions

2 messages · Agustin Lobo, Thomas Lumley

#
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,

I've made a personal misave() that excludes functions, but 
it might be a good idea having this as the default 
behaviour. Or perhaps, at least saving functions to
a text file (.Rtext) and the rest of objects 
as rda (.RData).

Just a suggestion.

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo at ija.csic.es


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 22 Feb 2002, Agustin Lobo wrote:
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.
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._