8

R Packages are installed to /usr/local/Cellar/r/3.1.2_1/R.framework/Versions/3.1/Resources/library

Whenever I run brew upgrade r and the version of R changes I need to install most of the libraries again as the path of installation changes.

How do I upgrade without having to install everything back again?

Edit: I think this answers my question http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows

BolzanoW
  • 665
  • 1
  • 6
  • 12
  • 3
    The expected location after a default installation is: `/Library/Frameworks/R.framework/Versions/3.1/Resources/library`. Using brew is not recommended by the maintainer of the OSX branch of R. And ... everyone who makes a major version update also needs to reinstall packages, so you may just be asking one of the R-FAQ questions. – IRTFM Jan 09 '15 at 18:31
  • I'm not familiar with R, but this occasionally also happens with Ruby, Python, etc. package environments. I might be a flaw in Homebrew. – Peter Eisentraut Jan 11 '15 at 22:59

3 Answers3

2

I put .libPaths("/Users/tim/.R/packages") in my ~/.Rprofile so that packages are installed to a path that doesn't disappear after a version bump.

Tim Smith
  • 6,127
  • 1
  • 26
  • 32
1

Expanding on other answers by including packages from BioConductor as well as CRAN.

  1. Before install: Backup current package list.

    tmp <- installed.packages() installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) save(installedpkgs, file="installed_old.rda")

  2. Install new version of R

  3. Reload packages from CRAN

    load("installed_old.rda") tmp <- installed.packages() installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) missing <- setdiff(installedpkgs, installedpkgs.new) install.packages(missing) update.packages()

  4. Reload packages from BioConductor

    chooseBioCmirror() biocLite() load("installed_old.rda") tmp <- installed.packages() installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) missing <- setdiff(installedpkgs, installedpkgs.new) for (i in 1:length(missing)) biocLite(missing[i])

dalloliogm
  • 8,718
  • 6
  • 45
  • 55
keberwein
  • 536
  • 4
  • 8
0
  1. Save a list of your packages as an R data file

    tmp <- installed.packages() installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) save(installedpkgs, file="installed_old.rda")

  2. Install new version

  3. Load the list, then download the old packages from CRAN

    oad("installed_old.rda") tmp <- installed.packages() installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) missing <- setdiff(installedpkgs, installedpkgs.new) install.packages(missing) update.packages()

keberwein
  • 536
  • 4
  • 8