Every time I update R with homebrew, I need to install most packages again

R Packages are installed on /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 installation path changes.

How can I upgrade without having to install everything back?

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

+5
source share
3 answers

I put .libPaths("/Users/tim/.R/packages") in my ~/.Rprofile so that the packages are installed on a path that does not disappear after the update.

+1
source

Extension to other answers, including packages from BioConductor, as well as CRAN.

  • Before installation: back up the current package list.

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

  • Install the new version of R

  • Reloading 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()

  • 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])

+1
source
  • Save the 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")

  • Install new version

  • Download 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 ()

0
source

Source: https://habr.com/ru/post/1210755/


All Articles