Updating Existing R Packages to a New Version of R

Venkatesh-Prasad Ranganath
1 min readJun 17, 2020

Recently, I upgraded to R 4.0.1. To avoid broken packages, I started updating installed packages using installed.packages() and install.packages(). This solution was less than ideal because, if a dependee package was not built for R 4.0.1, then the dependent package failed to build and install.

After some search, I stumbled on update.packages(pkgs, checkBuilt=T, ask=F) solution. While the documentation of update.packages says, “If checkBuilt is TRUE, a package built under an earlier major.minor version of R (e.g., 3.4) is considered to be ‘old’”, this command did not update the installed packages that were built for R 3.6.2 (according to the output of packageDescription function). I wonder if I am missing something here or if this is a bug.

Finally, I wrote the following R script to traversal the dependence graph of each installed package and updated the dependent packages in post-order. Look Ma, I am using graph algorithms to solve real problems :)

Hope you find the script useful!

--

--

Venkatesh-Prasad Ranganath

Engineer / Ex-Academic / Ex-Researcher curious about software and computing.