[R] Update R, keep packages

Eric Archer Eric.Archer at noaa.gov
Mon Dec 1 19:51:09 CET 2008


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:
> 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
>
> ______________________________________________
> 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.

-- 

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
3333 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 


"Innocence about Science is the worst crime today."
   - Sir Charles Percy Snow

"Lighthouses are more helpful than churches."
   - Benjamin Franklin

   "...but I'll take a GPS over either one."
       - John C. "Craig" George 




More information about the R-help mailing list