[R-sig-Debian] updating r-cran- packages on a new Ubuntu lucid system

Dirk Eddelbuettel edd at debian.org
Mon Jan 31 03:40:43 CET 2011


For what it's worth, I use the scriipt below (via ~/bin/update.r) which is
also an example script in the littler package.  

It _explicitly_ restricts the update to

    /usr/local/lib/R/site-library

so that the update from R is kept separate from the update via the Debian or
Ubuntu package manager.

Hope this helps,  Dirk



#!/usr/bin/r -t
#
# a simple example to update packages in /usr/local/lib/R/site-library
# parameters are easily adjustable

## adjust as necessary, see help('download.packages')
repos <- "http://cran.r-project.org"
## or use BioC's repo list if Biobase is installed:
suppressMessages(rc <- require(Biobase))
if (rc) {
  repos <- Biobase:::biocReposList()
}

## this makes sense on Debian where no package touch /usr/local
lib.loc <- "/usr/local/lib/R/site-library"

## simply unrolling of all unlink over all files 'repos*' in $TMP
clearCache <- function() {
  sapply(list.files(path=tempdir(), pattern="libloc*", full.names=TRUE), unlink)
}

## Always clear caches of remote and local packages
clearCache()

## r use requires non-interactive use
update.packages(repos=repos, ask=FALSE, lib.loc=lib.loc)

## Always clear caches of remote and local packages
clearCache()

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-SIG-Debian mailing list