Migrating R libraries Migrating R libraries r r

Migrating R libraries


Option #3 (copying old library to new library) should work ... but if and only if you then run:

update.packages(checkBuilt=TRUE)

In this manner the packages that need to be rebuilt for new versions will get updated. It is often the case that new versions add requirements (such as the impending requirement in 2.14.x for NAMESPACEs).

Edit: Seeing this is just moving around the deck chairs .... I'm going to back off from endorsing #3 if you are moving any of the base R installation. It has worked for me in a Mac, but I have not seen a promise in the R Installation and Administration Guide or the R FAQ that it should work. You can accomplish #1 (which is probably safest in various conditions) by this sequence:

# In original installation, get the non-default package list:save.pkg.list <- installed.packages()[is.na(installed.packages()[ , "Priority"]), 1]save(save.pkg.list, file="pkglist.Rdata")# If you want to use remove.packages() at this point it's fine. # Or just delete their directories.

With a freshly installed version of R with the .Libpaths set to your preferences (or even the same old installation):

load("pkglist.Rdata")install.packages(save.pkg.list)

Just moving the packages to a new library if the R executables was not changed might succeed (assuming you also change the .Libpaths) but I do not have a Linux installation to test it or know how any pointers set by configure operations would be affected.


Combining the accepted answer, with this one, I found a simpler solution that worked:

lib_loc <- "C:/Users/apdev/Documents/R/win-library/3.3"to_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])to_installremove.packages(to_install, lib="C:/Users/apdev/Documents/R/win-library/3.3")install.packages(pkgs = to_install, lib="C:/Program Files/R/R-3.6.1/library")