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

From: Prof Brian Ripley <>
Date: Thu 02 Feb 2006 - 07:45:55 GMT

On Wed, 1 Feb 2006, Seth Falcon wrote:

> On 1 Feb 2006, 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
> 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,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
Received on Thu Feb 02 18:51:57 2006

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:40 GMT