From ripley@stats.ox.ac.uk  Mon Oct 21 21:24:45 2002
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Mon, 21 Oct 2002 21:24:45 +0100 (GMT Daylight Time)
Subject: RFC: Loading packages at startup
Message-ID: <Pine.WNT.4.44.0210212122030.3056-100000@petrel>

I've been kicking the following idea around for a while, and am now
proposing to put some version into 1.7.0.  I'd be interested in
comments on the desirability and the design, before I start writing
any code.

S4 introduced a file .S.chapters which can contain a list of S
chapters (equivalent to R packages) to be loaded on start-up.  This
was the germ of this proposal.

Proposal:

Extend the initialization as described in Startup.Rd by having
optionally files named, say, R_HOME/etc/Rpackages.site and .Rpackages,
the latter in the starting directory or failing that the user's home
directory. Each would contain a list of packages, one per line, to be
loaded when R is started, in the order in the files.

Some details:

1) I think the packages should be loaded before .Rprofile and .RData
   are processed, and R_HOME/etc/Rpackages.site before .Rpackages.
   This can be argued, and the S4 parallel would seem to be to load
   packages after S.init (the nearest it has to Rprofile).  But we
   would load library/base/Rprofile first of all so the analogy is not
   close.

2) The present kludge of loading ctest in .First could be replaced
   by making ctest the default content of R_HOME/etc/Rpackages.site
   (in the light of point 5).

3) It would be useful to allow the library tree to be specified, as a
   second field on the line.

4) One problem with saving an R session and then restoring it is that
   the packages in use are not reloaded.  Quitting an R session and
   saving could write .Rpackages in the current directory (with the
   library recorded if it were not the default).  Then restarting a
   session in that directory would restore the loaded packages
   automatically.

5) We might want to allow a .Rpackages file to override Rpackages.site
   (or we might not).  One idea is to allow a minus sign in front of a
   package name, and to merge the Rpackages.site and .Rpackages files
   before loading any packages.  If we did this we probably need to be
   able to save the list of packages to be loaded (and can't easily save
   those not to be loaded), so perhaps -- as the first list of .Rpackages
   should empty the list.

6) One could argue for R_HOME/etc/Rpackages as the `system' file as
   well, and this might be useful if we break base up into smaller
   components.

7) I would allow comment lines in the files, starting with #.

8) The file names or names could be set by environment variables.  It's
   strange that we allow the site file names for Rprofile and Renviron and
   the user file name for command histories to be set in that way.

-- 
Brian D. Ripley,                  ripley@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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


RFC: Loading packages at startup
Prof Brian D Ripley