[Rd] how to control which version of a package library() installs?

Tony Plate tplate at acm.org
Fri Apr 13 22:52:28 CEST 2007


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 
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.

$ 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



More information about the R-devel mailing list