Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically update packages installed from R-forge

Tags:

r

r-forge

I recently installed R-2.12.0 from R-2.11.1 and I've updated all CRAN packages via:

update.packages(checkBuilt=TRUE, ask=FALSE) 

Now I want to update all the packages I have installed from R-forge, but only if they're not available on CRAN. In other words, I cannot simply run:

update.packages(checkBuilt=TRUE, ask=FALSE, repos="http://r-forge.r-project.org") 

because it would install the R-forge version of the survival package over the version that came with R-2.12.0.

I could probably use some combination of the information from old.packages and packageStatus to determine which packages exist only on R-forge, but I wanted to ask if there was an easier way before building a custom solution.

like image 414
Joshua Ulrich Avatar asked Oct 19 '10 19:10

Joshua Ulrich


People also ask

Does R automatically update packages?

As far as I know, there are no automatic updates for R, RStudio and packages. And as updates are quite frequent, it is quite a hassle to check every few weeks (or even days) if there are new versions available.

How do I update R packages?

If you only want to update a single package, the best way to do it is using install. packages() again. In RStudio, you can also manage packages using Tools -> Install Packages.

Should I update packages in R?

If you're updating R itself, you should update your packages. Depending on your installation, R will make a new directory for packages anyway, so you either have to relink your old set or reinstall them. If you're going to relink, update and rebuild, or you'll likely get a lot of annoying warnings later to do so.


1 Answers

How about this:

# 1. Get the list of packages you have installed,  #    use priority to exclude base and recommended packages. #    that may have been distributed with R. pkgList <- installed.packages(priority='NA')[,'Package']  # 2. Find out which packages are on CRAN and R-Forge.  Because #    of R-Forge build capacity is currently limiting the number of #    binaries available, it is queried for source packages only. CRANpkgs <- available.packages(   contriburl=contrib.url('http://cran.r-project.org'))[,'Package'] forgePkgs <- available.packages(   contriburl=contrib.url('http://r-forge.r-project.org', type='source') )[,'Package']  # 3. Calculate the set of packages which are installed on your machine, #    not on CRAN but also present on R-Force. pkgsToUp <- intersect(setdiff(pkgList, CRANpkgs), forgePkgs)  # 4. Update the packages, using oldPkgs to restrict the list considered. update.packages(checkBuilt=TRUE, ask=FALSE,   repos="http://r-forge.r-project.org",   oldPkgs=pkgsToUp)  # 5. Profit? 
like image 182
Sharpie Avatar answered Sep 28 '22 05:09

Sharpie