[R] Load and unload libraries
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Apr 1 12:53:06 CEST 2003
On 1 Apr 2003, Rita Ribeiro wrote:
> On Tue, 2003-04-01 at 10:53, Prof Brian Ripley wrote:
> > 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?
>
> Yes, sorry.
> Packages in tar.gz files which I have installed with R CMD INSTALL in
> different locations, just to test different things.
>
> The library locations are the paths to where the packages have been
> installed.
>
> Here's a small simulation:
>
> > library(mylib,lib.loc1)
> > .path.package("mylib") # returns lib.loc1
> (...)
> > detach('package:mylib')
> > .path.package("rpart")
> Error in .path.package(mylib) : none of the packages are loaded
> > exists("mylib") # returns FALSE
>
> > library(mylib,lib.loc2)
> > .path.package("mylib") # returns lib.loc2
> or
> > .find.package("mylib") # returns lib.loc2
>
> The problem is when I invoke mylib function: it uses the binary code
> from the first library location.
>
> Is there anyway of "unloading" the first library to load a new one,
> although with the same name. Ie is there anyway of getting a "cleanup"
> state?
If you mean shared library, yes. See the .Last.lib function in
src/library/tcltk/R/windows/zzz.R. Don't do this if you have used the
registration functions, though.
> Should I give different names to the packages to solve the problem? I
> preferred no to....
It's what R expects.
--
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