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 confid...{{dropped:17}}
Charles Annis, P.E.
2008-Jan-14 23:58 UTC
[R] unload & reload a (new version of a) package
I may not understand things, but what I do with my home-brew package in Windows is this: First detach the current package - Type detach("package:your.package") <enter> Next, click on Packages, Install package(s) from local zip files, and click on the updated zip file. Finally, click on Packages, Load package ... , and click on your.new.package in the drop-down menu. Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----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 confid...{{dropped:9}}
See ?detach, in particular the 'unload' argument and "Details" (issues involve namespaces & methods, among other things). Also, note that if the package loaded any compiled code (DLL's in Windows), some OS's do not support unloading & reloading these. -- Tony Plate Harte, Thomas P wrote:> 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 confid...{{dropped:17}} > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
On Jan 14, 2008 5:48 PM, Harte, Thomas P <THarte at tiaa-cref.org> wrote:> 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?For testing, I usually just re"source" all of my code: lapply(dir("~/documents/ggplot/ggplot/R", full.name=T), source) obviously it's no good for testing data, namespaces or compiled code, but 95% of the time it's good enough for me. Hadley -- http://had.co.nz/