[R] Load and unload libraries

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 1 11:53:23 CEST 2003

On 1 Apr 2003, Rita Ribeiro wrote:

> I'm having some problems in loading libraries. I wonder if anyone can
> help me with this.
> I have created two libraries with the same name at different locations.

Do you mean packages?

> I want to use both of them, one at a time.
> So I do:
> library(mylib,lib.loc1)
> (....)
> detach('package:mylib')
> library(mylib,lib.loc2)
> The problem is that, after this, the used library is still the one first
> loaded.
> Isn't detach command enough? 

Not in general. detaching a package does not in general unload any 
*library* (DLL, shared library, dynamic library, name depending on OS)
that was loaded.  If there are no namespaces involved (a new feature of 
1.7.0) it should give you the second version of the R code, and it did so 
when I just did an experiment.

I'm afraid you will need to be more precise in your terminology and give 
us more details.

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