[Rd] The install.R and R_PROFILE.R files

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 2 08:45:55 CET 2006


On Wed, 1 Feb 2006, Seth Falcon wrote:

> On  1 Feb 2006, ripley at stats.ox.ac.uk wrote:
>> Every usage of these on CRAN is unnecessary. If you want to save the
>> image, say so in the SaveImage field in DESCRIPTION (but why not
>> LazyLoad instead?).  If you require methods, say so in Depends in
>> DESCRIPTION.
>
> I've looked over the packages in the Bioconductor repository and I
> believe that every usage of R_PROFILE.R and install.R is also
> unnecessary.

Thanks for that.

>> (b) A package that requires a saved image (and lazy loading is
>> insufficient)?
>
> Many Bioc packages use SaveImage in their DESCRIPTION file.
>
> Could someone provide more detail on the difference between SaveImage
> and LazyLoad.  It is possible that LazyLoad would do just as well.

When an R package is installed, a file is prepared which is the 
concatenation of the (valid) files in the R directory.

With SaveImage, that file is loaded into an environment, and the 
environment dumped as a all.rda file.  The R code is then replaced by 
a loader whose sole job is to load the all.rda file.

With LazyLoad, the R file is loaded into an environment, and the objects 
in the environment are dumped individually into a simple database. The R 
code is then replaced by a loader whose sole job is to create an 
environment of promises to load the objects from the database.
(There is an article in R-news about lazy-loading.)

Lazy-loading is the norm for all but packages with very small amounts of R 
code.

I don't know when saving an image might be needed in preference to 
lazy-loading.  The differences in space (and hence time) when the package 
is used can be considerable, in favour of lazy-loading.  Since saving the 
objects in an environment and saving an environment are not quite the same 
thing there are potential differences.  (I have forgotten, if I ever knew, 
what happens with lazy-loading when you have an object whose environment 
is another namespace, for example.)

There have been packages ('aod' and 'gamlss' are two) which have both 
SaveImage and LazyLoad true. That works but is wasteful.

I just looked at the 12 non-Windows CRAN packages with SaveImage: yes and 
replaced this by LazyLoad: yes.  All passed R CMD check after the change. 
This included 'debug' and 'mvbutils' which had SaveImage: yes, LazyLoad: 
no which suggests the author thought otherwise.

There is no intention to withdraw SaveImage: yes.  Rather, if lazy-loading 
is not doing a complete job, we could see if it could be improved.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list