Loading packages at startup
Tue, 22 Oct 2002 20:23:41 +0100 (BST)
On 22 Oct 2002, Timothy H. Keitt wrote:
> [Sorry, just noticed this thread and don't know what's been said
> already, but I will comment nonetheless.]
Actually this is a spin-off from a small point in an RFC posted earlier,
and I think it would have been kinder to have done your homework.
A serious proposal is getting sidetracked by half-formulated ways
(even buggy ones) to solve a related but different problem.
> I've also thought about this problem and I think we should be careful to
> make sure its solved in a very general manner. Objects bind methods to
> data, but this is broken when saving and reloading R sessions (only the
> data ends up in .RData and not the bindings). What happens if someone
> has multiple saved R sessions in a single directory? A single .Rpackages
> file would either leave out packages or have to include all packages
> across all sessions.
Eh? Only one session is saved and reloaded in .RData per directory.
And we only have one .Rprofile and one .Renviron per directory.
So everyone I have ever seen uses separate directories for separate
If you go back and read the RFC, you will see the idea was that
users could specify the packages they wanted loaded (and in which order)
on a per-directory basis. *Or not.* The idea of rewriting it at the end
of a session was just one of the possible extensions.
I would find this very useful, and although I could use .First (prone to
getting damaged) or .Rprofile I would prefer a separate mechanism. Not
least, I would like to use ~/.Rprofile for all my work (turn off
significance stars etc) and a per-directory .Rpackages.
> I would far rather have a mechanism that recognizes
> an object as an object and lets that object load the appropriate
> bindings to methods at (re)instantiation. I once proposed that there be
Not possible with S3 methods and loose inheritance. You cannot tell what
package the methods an object needs is in. Nor if it is in several can you
tell which one the user was preferring. What we can do is to
restore the search list to (more or less) what it was at the end of the
last session, *if we want to*.
Nor is it possible to load packages arbitrarily, as the order does matter.
> function hooks in the save/load process that could be overloaded by
> object type to make sure that any initializations (including package
> loading) could be completed before attaching the data. This would also
> allow for example database objects to reestablish their connections when
> a session is reloaded from disk.
Again, not possible with S3 classes. I am not sure if it is possible with
formal methods as currently implemented, but it would need that sort of
Brian D. Ripley, email@example.com
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: firstname.lastname@example.org