Reinstall packages after updating R

When you change R version, you must reinstall manually all your installed packages.

# before to update

pkgins <- rownames(installed.packages())
save(pkgins, file = "pkgins.Rdata")

# after updating

load(file = "pkgins.Rdata")
for (pkg in pkgins[is.na(match(pkgins, rownames(installed.packages())))]) {
  if (pkg %in% pkgins[is.na(match(pkgins, rownames(installed.packages())))]) {
    install.packages(pkg)
  }
}

The packages shown with:
pkgins[is.na(match(pkgins, rownames(installed.packages())))]
Are not available in CRAN or produced an error when installed with new version.

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04