Skip to content
Prev 163482 / 398502 Next

Update R, keep packages

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: