[R] What is a sane way to deal with changes in library loadings after 1.9.0?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jul 5 12:51:25 CEST 2004


On Mon, 5 Jul 2004 a.prioglio at city.ac.uk wrote:

> On Mon, Jul 05, 2004 at 11:59:59AM +0200, Peter Dalgaard wrote:
> > > As I am using R on different machines, some are version 1.8.1 and some
> > > 1.9.1.
> > > 
> > > One of the changes between these versions is the change in default
> > > libraries loaded when reading scripts.
> > > 
> > > So I started my scripts with:
> > > 
> > > if (R.version$minor>="9.0") {
> > > 	library(utils)
> > > 	library(graphics)
> > > 	library(stats)
> > > }
> > > 
> > > It appeard to work but now I get "could'n find function factanal" in
> > > version 1.8.1.
> > 
> >  help.search("factanal") should get you there in a jiffy...
> 
> Yes! True thanks.
> > 
> > 
> > > What would be a safe and sane way to ensure all relevant libraries are
> > > loaded irrespective of version?
> > 
> > They're back-compatible (for a while yet) -- library(mva) will get you
> > the stats package, so just including the packages that were relevant
> > for 1.8.x should do. There are a few cases where you'll include too
> > much, e.g. som things were moved from MASS into stats, so these days
> > you might not require MASS where you did before, but that is a
> > relatively rare situation.
> 
> Well, I'm certainly new to R. Still without the explicit loading of the
> above libraries my scripts while loading on 1.8.1 were definetely not
> loading on 1.9.1. I'm using the same account on all machines so I expect
> to have the same environment. Or should I?
> 
> One thing I noticed now, a search() on a 1.8.1 machine after the loading
> of the scripts now returns nothing (after encountering an error though).

And what was the error?

It seems that you have been fiddling with the default set of packages.
Have you set R_DEFAULT_PACKAGES?  Have you set option "defaultPackages"?
If so, set them to "", or try starting R with --vanilla.

Packages utils, graphics and stats are loaded by default on 1.9.1.  And
package mva is loaded by default on 1.8.1.  People who answer here tend to
assume that people who know enough to change the default packages loaded
know enough to revert the changes ....

> How can one know what environments are loaded? Calling R --verbose did
> not seem to clarify this point.

search()  (attached, not loaded, BTW, as there are loaded namespace 
environments which are not attached).

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




More information about the R-help mailing list