Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update existing packages to new version of R
library(gtools)
update <- function(p) {
pd <- packageDescription(p, fields=c('Built'))
pd <- gsub(";.*", "", pd)
if (!is.na(pd) && pd != 'R 4.0.1') { # mention the target versions here
for (d in getDependencies(p)) {
update(d)
}
install.packages(p)
}
}
packages <- rownames(installed.packages())
for (p in packages) {
update(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment