[Rd] require vs library
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Sun Feb 23 08:28:03 2003
On Sat, 22 Feb 2003, kjetil brinchmann halvorsen wrote:
> On this theme, I have another question. I have a package
> which needs another package (SuppDists) for only one
> function. I do require() within that function only. Is that OK,
> or should it be done within .First.lib ?
Yes, that's fine. I should have stressed *at the top level* below.
In one scenario we have been experimenting with the objects in a package
are dumped to a database, and then loading the package makes the objects
available as promises and no longer executes the original package code.
Another scenario is to install with --save.
> > Another point: please do not call code with side effects like require,
> > library or options at the top level in foo/R/foo, but do so within
> > .First.lib. This becomes important if the code is dumped or put in a
> > database.
--
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595