Wednesday, December 12

How to upgrade R version without losing your existing installed packages


R is a language & environment for statistical computing and graphics. R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand. Currently it is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories.

Here are the steps I performed to reuse the downloaded libraries (saves the paint o reinstall each library) when I upgraded R from 3.5.0 to 3.5.1.

Before any update of R, start the software or Rstudio to know where all packages are installed by typing - .libPaths()

1. Before you upgrade, build a temp file with all of your old packages.



tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")
 
2. Install the new version of R ( as of Oct 2018 latest version is R3.5.1)
3. Once you’ve got the new version up and running, reload the saved packages and re-install them from CRAN.




tmp <- installed.packages()
installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
missing <- setdiff(installedpkgs, installedpkgs.new)
install.packages(missing)
update.packages()

No comments:

Post a Comment

MUSTREAD : How can you use Index Funds to help create wealth? HDFC MF Weekend Bytes

https://www.hdfcfund.com/knowledge-stack/mf-vault/weekend-bytes/how-can-you-use-index-funds-help-create-wealth?utm_source=Netcore&...