[R] auto-loading package possible?

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Tue Jul 2 15:01:50 CEST 2002

There is nothing that associates classes with packages.  So one would have
to have print() look at all packages (loaded or not) for a print.foo
method and load the appropriate one.  Now suppose it found three print.foo
functions in separate packages?  Which one should it use?

There is also the potential for an enormous slowdown whilst packages are

However, I do have a vision which would allow users to load many packages
at negligible cost and so one could have all one's working set of packages
in .Rprofile (or some such file).  This depends on two things

1) Packages declaring their list of public objects (which will come soon
with namespaces), and these would be automatically auto-loaded and

2) Small-scale autoloading, so a package is divided into a set of code
sections which are loaded as needed.

Then one could have many packages `loaded' via library(), but only code
that has actually been used in memory.

Don't expect to see an implementation any time soon, though.  (One issue
is interactions with namespaces.)

On Tue, 2 Jul 2002, Liaw, Andy wrote:

> Dear R-help,
> Yes, I do know about the auto-loading feature.  My question is more
> complicated than that:
> Suppose I loaded a package (e.g., e1071) and created an object of certain
> class (e.g., svm), for which there is a print method in the package to hide
> things that the user may not need to see (e.g., large vectors or matrices
> needed by methods such as predict).  If the next time I started R, I type
> the object name without loading the package first, the whole shebang (sp?)
> gets dumped on the screen, which is quite annoying.
> Is there any way to make R automagically search for availability of methods
> for a particular class when objects of that class is accessed?  One
> possibility is to auto-load the package if the appropriate method is found.
> Another possibility is to notify the user that a package contains the
> appropriate method and ask if it should be loaded.  Can such a thing be
> done?
> Regards,
> Andy
> Andy I. Liaw, PhD
> Biometrics Research          Phone: (732) 594-0820
> Merck & Co., Inc.              Fax: (732) 594-1565
> P.O. Box 2000, RY84-16            Rahway, NJ 07065
> mailto:andy_liaw at merck.com
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.
> ==============================================================================
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

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

r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list