Chris Howden
2010-Oct-20 02:07 UTC
[R] is there a way to update both packages if they occur in 2 libraries?
Hi everyone, I’ve recently added a private library as a way to manage my R libraries. And I did this by simply copying my old library to a new folder and then linking this to R by setting my R_LIBS environmental variable in .Renviron. However I have run into a problem. When I update my packages it is not updating those that are current in the base R library. This means I can’t load packages that are included in base R, since R is looking in my private library first and when it finds the package it tries to use it. But it’s an outdated version. The easiest solution I can think of is to update both libraries, but when I run update.packages(lib.loc=”private library location” ask = FALSE, checkBuilt=TRUE) it’s not updating them. So I was wondering if there is a way to update all packages that occur in all libraries? (Note that I can think of other solutions to my problem, but they are all time consuming and defeats the purpose of why I want a private library i.e. it makes updating R easier since I don’t need to copy over the library folder each time nor update any environmental variables. So far the best alternative I’ve come up with is to delete all the duplicate base R libraries from my private library) If anyone is interested the code I used to understand my problem is below. Thanks everyone> update.packages(lib.loc="C:\\Program Files\\R\\library", ask = FALSE,checkBuilt=TRUE) --- Please select a CRAN mirror for use in this session ---> update.packages(ask = FALSE, checkBuilt = TRUE)Foreign package won’t load> library(foreign)Error: package 'foreign' was built before R 2.10.0: please re-install it> .libPaths()[1] "C:\\Program Files\\R\\library" "C:/PROGRA~1/R/R-212~1.0/library"> .libPaths("new")> .libPaths()[1] "C:/PROGRA~1/R/R-212~1.0/library" Foreign package will load> library(foreign)Chris Howden Founding Partner Tricky Solutions Tricky Solutions 4 Tricky Problems Evidence Based Strategic Development, IP development, Data Analysis, Modelling, and Training (mobile) 0410 689 945 (fax / office) (+618) 8952 7878 chris@trickysolutions.com.au [[alternative HTML version deleted]]
Uwe Ligges
2010-Oct-20 11:44 UTC
[R] is there a way to update both packages if they occur in 2 libraries?
update.packages() updates all packages in all libraries listed in .libPaths() unless you specify an explicit library. It may happen that the version number has not changed and you just want to reinstall for your upgraded R. In that case use: update.packages(checkBuilt=TRUE) Best, Uwe Ligges On 20.10.2010 04:07, Chris Howden wrote:> Hi everyone, > > > > I?ve recently added a private library as a way to manage my R libraries. And > I did this by simply copying my old library to a new folder and then linking > this to R by setting my R_LIBS environmental variable in .Renviron. > > > > However I have run into a problem. > > > > When I update my packages it is not updating those that are current in the > base R library. > > > > This means I can?t load packages that are included in base R, since R is > looking in my private library first and when it finds the package it tries > to use it. But it?s an outdated version. > > > > The easiest solution I can think of is to update both libraries, but when I > run update.packages(lib.loc=?private library location? ask = FALSE, > checkBuilt=TRUE) it?s not updating them. > > > > So I was wondering if there is a way to update all packages that occur in > all libraries? > > > > > > (Note that I can think of other solutions to my problem, but they are all > time consuming and defeats the purpose of why I want a private library i.e. > it makes updating R easier since I don?t need to copy over the library > folder each time nor update any environmental variables. So far the best > alternative I?ve come up with is to delete all the duplicate base R > libraries from my private library) > > > > If anyone is interested the code I used to understand my problem is below. > > > > > > Thanks everyone > > > > > > > >> update.packages(lib.loc="C:\\Program Files\\R\\library", ask = FALSE, > checkBuilt=TRUE) > > --- Please select a CRAN mirror for use in this session --- > > > >> update.packages(ask = FALSE, checkBuilt = TRUE) > > > > Foreign package won?t load > >> library(foreign) > > Error: package 'foreign' was built before R 2.10.0: please re-install it > > > >> .libPaths() > > [1] "C:\\Program Files\\R\\library" "C:/PROGRA~1/R/R-212~1.0/library" > > > >> .libPaths("new") > > > >> .libPaths() > > [1] "C:/PROGRA~1/R/R-212~1.0/library" > > > > Foreign package will load > >> library(foreign) > > > > > > > > > > > > Chris Howden > > Founding Partner > > Tricky Solutions > > Tricky Solutions 4 Tricky Problems > > Evidence Based Strategic Development, IP development, Data Analysis, > Modelling, and Training > > (mobile) 0410 689 945 > > (fax / office) (+618) 8952 7878 > > chris at trickysolutions.com.au > > [[alternative HTML version deleted]] > > > > > ______________________________________________ > 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.