Skip to content

Use of R_PROFILE.R / install.R

3 messages · Kurt Hornik, Brian Ripley

#
According to R-exts:

  The second purpose for @file{install.R} is to hold code that needs to be
  executed each time the package is attached, after the image is
  loaded.  Few packages have a need for such code so @file{install.R} is
  normally an empty file.

  The optional file @file{R_PROFILE.R} is executed before the code in the
  @file{R} subdirectory and should be used to set up an environment needed
  only to evaluate the code (which is run with the @option{--vanilla}
  command-line flag).  Very few packages will need such code.
  Indeed, both @file{install.R} and @file{R_PROFILE.R} should be viewed as
  experimental; the mechanism to execute code before attaching or 
  installing the package may change in the near future.

(Actually it's during loading, not attaching, a namespace, for packages
with namespaces.)

Looking on CRAN, it seems that two packages use R_PROFILE.R for
`options(echo=FALSE)', which does not do anything useful AFAICS.  A
non-empty install.R is used for

require(methods)
require(boot)
require("Hmisc")
data(Wcrit.R)

and that's not the intention (and in particular require() should have its 
return value checked!) -- this is best done in .First.lib/.onLoad.

One problem is that the package has no way to prevent a saved image being 
forced with INSTALL --save.


Since this mechanism is a maintenance nightmare (especially with
lazy-loading +/- saving images) I propose we drop it for 2.0.0.  Instead,
just as for lazy-loading, we should have a field in the DESCRIPTION file,
with

SaveImage: yes

forcing saving the image, and any other value forcing not saving it.

Note that most packages which currently save an image probably want to 
use lazy-loading instead and so should have LazyLoad: yes in their 
DESCRIPTION file.

The proposed change is not backwards compatible but affects very few CRAN 
packages, for all of which there is better solution that is backwards 
compatible.  I have not looked at BioConductor or elsewhere, so please 
will package authors let us know of any examples where R_PROFILE.R or 
install.R is essential (and why).
#
Fine with me.

Can we perhaps agree to allow both yes/no and true/false for such
logical package DESCRIPTION metadata (and also irrespective of case)?

-k

        
#
On Mon, 9 Aug 2004, Kurt Hornik wrote:

            
I've allowed yes/Yes and no/No already.  I can fairly easily allow
true/false, but FaLSe is a little more difficult ....

It looks like Bioconductor has many examples so it will take longer to 
convert those.  The new mechanism is in place now, though.