On Fri, 13 Apr 2007, Tony Plate wrote: > library() seems to remember the location of a package when I give it a > lib.loc, and then use that version thereafter, even if I don't supply
Not quite: it notices that it is loaded and does not load it again, possibly attaching the exports of a still-loaded namespace. > lib.loc again. Is there any way I can load different versions of a > package in one R session? -- I don't seem to able to simply detach the > package and then load a different version from a different library location. Without the output of search(), searchpath() and loadedNamespace() we cannot know what happened here. But here is an example of my own > library(Matrix, lib.loc="~/R/test26") Loading required package: lattice > searchpaths() [1] ".GlobalEnv" [2] "/data/gannet/ripley/R/test26/Matrix" ... > detach(2) > search() [1] ".GlobalEnv" "package:lattice" "package:stats" [4] "package:graphics" "package:grDevices" "package:utils" [7] "package:datasets" "package:methods" "Autoloads" [10] "package:base" > library(Matrix, lib.loc="~/R/test-library") > searchpaths() [1] ".GlobalEnv" [2] "/data/gannet/ripley/R/test26/Matrix" ... The point is that the namespace Matrix is still loaded. > detach(2) > unloadNamespace("Matrix") > library(Matrix, lib.loc="~/R/test-library") > searchpaths() [1] ".GlobalEnv" [2] "/data/gannet/ripley/R/test-library/Matrix" Might your example be similar? > $ R > [...startup info...] > > # only version we currently know about is in the standard library > > .find.package("ExamplePackage") > [1] "c:/R/R-2.4.1/library/ExamplePackage" > > # load a version from a different library e:/devinst > > library(ExamplePackage, lib.loc="e:/devinst") > > # and check we've got the right version ... yes > > system.file(package="ExamplePackage") > [1] "e:/devinst/ExamplePackage" > > .find.package("ExamplePackage") > [1] "e:/devinst/ExamplePackage" > > detach(2) > > > > # Now I'd like to load the version in the standard library. > > # .find.package() finds the version I want > > .find.package("ExamplePackage") > [1] "c:/R/R-2.4.1/library/ExamplePackage" > > # but library() loads the same version it did before, even > > # though I don't supply lib.loc, and .libPaths is untouched. > > library(ExamplePackage) > > system.file(package="ExamplePackage") > [1] "e:/devinst/ExamplePackage" > > .find.package("ExamplePackage") > [1] "e:/devinst/ExamplePackage" > > .libPaths() > [1] "c:/R/R-2.4.1/library" > > sessionInfo() > R version 2.4.1 (2006-12-18) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MON > ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United > States.1252 > > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > other attached packages: > ExamplePackage > "1.0" > > > > Am I doing something wrong here? I can't find any mention of > persistence of package location in ?library. > > thanks for any help or suggestions, > > Tony Plate > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Brian D. Ripley, [EMAIL PROTECTED] 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 ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel