10  Update R - Bare Bones

Author

Chrissy h Roberts

10.1 Bare bones updater for R.

An annoying feature of R is that updating the R version doesn’t always (if ever) pull all of your installed packages in to the new version.

Updater packages for R are also a bit hit and miss.

The updateR package is quite popular, but I haven’t had much luck with it.

It is here if you want to try it…

devtools::install_github(“AndreaCirilloAC/updateR”)

My approach is very simple. Save a list of installed (i.e. non core packages), then manually update using R’s install packages, then read the list of installed packages back in and install them.

10.2 Update R

10.3 Save list of libraries to system

options(repos = c(CRAN = "https://cran.rstudio.com"))
ip <- installed.packages()
pkgs <- ip[!ip[, "Priority"] %in% c("base", "recommended"), "Package"]
saveRDS(pkgs, "~/r-packages-before-update.rds")

Then go to R’s install page and install the newest version

https://cran.rstudio.com/bin/macosx/

10.4 Restore libraries

options(repos = c(CRAN = "https://cran.rstudio.com"))
pkgs <- readRDS("~/r-packages-before-update.rds")
already_installed <- installed.packages()[, "Package"]
to_install <- setdiff(pkgs, already_installed)
install.packages(to_install)
update.packages(ask = FALSE, checkBuilt = TRUE)

The downloaded binary packages are in
    /var/folders/kp/gr75h12s2gn3lbt3mcscb59r0000gp/T//Rtmp0PoTLS/downloaded_packages