Skip to content

Update R, keep packages

3 messages · Wilmar Igl, Uwe Ligges, Eric Archer

#
Hi,

when updating R I continuously face the problem that I have to reinstall 
packages or copy them into the new R library path.

Is there a smart way of configuring R (.Rprofile) so the packages 
installed under older R versions (different lib paths) are 
included/found by newer R versions (e.g. R site archive).
What problems due to version conflicts/out-of-date packages can arise?

I am working with R on a Linux server.

Thanks in advance,

Will
#
Will wrote:
See the manual R Installation and Administration on how to use library 
trees and how to update all packages for the recent version of R. If you 
do not recompile / update for a new major release of R, some packages 
(and packages that depend on them) may not work anymore (due to API 
changes, changes in S4 classes and so on).

Uwe Ligges
#
Will,

Below are the contents of my Rprofile.site file.  It makes sure that I 
have all of the packages I use regularly always up to date every time I 
start R.
I don't know if it is the "smart" way, but it works for me.  I'd be more 
than happy to get suggestions on improvements from the expeRts.

Cheers,
eric


local({
  repos <- getOption("repos")
  repos["CRAN"] <- "http://cran.stat.ucla.edu"
  options(digits = 3, stringsAsFactors = FALSE, repos = repos)
  library(grDevices)
  windows.options(record = TRUE)
  library(utils)
  update.packages(ask = FALSE)
  my.packages <- c("adapt", "ade4", "ape", "BRugs", "cluster", "coda", 
"fields", "gpclib",
    "Geneland", "genetics", "gpclib", "Hmisc", "lattice", "mapproj", 
"maps", "maptools",     "MASS",
    "R.oo", "R.utils", "randomForest", "rmetasim", "rpart", "sgeostat", 
"shapefiles",
    "sm", "sp", "spatial", "spatstat", "splancs")
  to.download <- which(!my.packages %in% rownames(installed.packages()))
  if(length(to.download) > 0) install.packages(my.packages[to.download], 
clean = TRUE)
})
Will wrote: