[R] unload & reload a (new version of a) package
Harte, Thomas P
THarte at tiaa-cref.org
Wed Feb 6 17:21:44 CET 2008
i returned to this problem and found that the solution was a disarmingly
straight-forward oversight on my part: 'detach' requires the version
number of the library to be specified!
thus, if you install packages '--with-package-versions' switched on,
and if you load the version of choice in an R session with:
> library(foo, version="1.0")
then you must 'detach' it in the same R session using
> detach(foo, version="1.0")
in the *same* R session you can load another version:
> library(foo, version="1.2")
and happily detach it with
> detach(foo, version="1.2")
and then go back to version 1.0 again (all in the same R session):
> library(foo, version="1.0")
thus obviating the behavior that i had previously reported.
-----Original Message-----
From: Harte, Thomas P
Sent: Tuesday, January 15, 2008 10:47 AM
To: r-help at r-project.org
Subject: RE: [R] unload & reload a (new version of a) package
update: this phenomenon disappears if i do a straight install *without*
package versioning, i.e.
C:\packages>c:\R\R-2.6.1\bin\R CMD BUILD foo_1.0
[creates foo_1.0.tar.gz]
C:\packages>c:\R\R-2.6.1\bin\R CMD INSTALL -l c:/library foo_1.0.tar.gz
i can update the package, re-build and re-install and load it into the
existing R session with a call to 'library(foo, lib.loc="c:/library")'
when i posted, i had been doing things *with versioning* switched on:
C:\packages>c:\R\R-2.6.1\bin\R CMD BUILD foo_1.0
[creates foo_1.0.tar.gz]
C:\packages>c:\R\R-2.6.1\bin\R CMD INSTALL --with-package-versions -l
c:/library foo_1.0.tar.gz
and loading it into the existing R session with 'library(foo,
lib.loc="c:/library", version="1.0")'.
so the problem seemes to exist if i install a newer version of the
package this way, thereby clobbering the old version foo_1.0 in the
process. however, if I copy the source tree for foo_1.0 and make a
*completely new version* foo_1.1, say, and install
--with-package-versions:
C:\packages>c:\R\R-2.6.1\bin\R CMD BUILD foo_1.1
C:\packages>c:\R\R-2.6.1\bin\R CMD INSTALL --with-package-versions -l
c:/library foo_1.1.zip
library(foo, lib.loc="c:/library", version="1.1")
then i can successfully load version 1.1
something is possibly wrong somewhere with versioning, or with my
package. either way, i can live without versioning switched on and just
clobber versions of the library foo with the updated package foo.
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Harte, Thomas P
Sent: Monday, January 14, 2008 6:49 PM
To: r-help at r-project.org
Subject: [R] unload & reload a (new version of a) package
i'm putting the final touches on a package that i'm developing and i
noticed that if i detach the package, and then re-build & re-install it
(using R
CMD)
then I can't get the newer version of the package to load in the
existing R session (i have to close it out and start a new session, then
the newer
version of the package is loaded).
looking through the source of 'detach' i see :
.Call("R_lazyLoadDBflush", paste(libpath, "/R/", pkgname,
".rdb", sep = ""), PACKAGE = "base")
is there some absolute way similar to the above to flush the package db
and ensure that a newer version of the package can be loaded into the
existing R session? detach calls .Last.lib and seems to go through the
motions of purging the loaded package; why, then, is the package still
lurking around in the existing R session?
it's not a big deal; it's only a minor pain having to re-start an R
session. i'm more interesting in why this is happening.
cheers,
thomas.
************************************************************************
****
****************
This message, including any attachments, contains\ confi...{{dropped:26}}
More information about the R-help
mailing list