Everytime I upgrade R using homebrew I need to install most packages again

孤人 提交于 2019-12-05 05:15:39

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.

keberwein

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

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!