Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Painless way to install a new version of R?

Andrew Gelman recently lamented the lack of an easy upgrade process for R (probably more relevant on Windows than Linux). Does anyone have a good trick for doing the upgrade, from installing the software to copying all the settings/packages over?

This suggestion was contained in the comments and is what I've been using recently. First you install the new version, then run this in the old version:
#--run in the old version of R
packages <- installed.packages()[,"Package"]
save(packages, file="Rpackages")

Followed by this in the new version:
#--run in the new version
for (p in setdiff(packages, installed.packages()[,"Package"]))

2 Answers

Two quick suggestions:

Use Gabor's batchfiles which are said to comprise tools helping with e.g. this bulk library relocations. Caveat: I have not used them.

Don't install libraries within the 'filetree' of the installed R version. On Windows, I may put R into C:/opt/R/R-$version but place all libraries into C:/opt/R/library/ using the following snippet as it alleviates the problem in the first place:

$ cat .Renviron         # this is using MSys/MinGW which looks like Cygwin  
## Example .Renviron on Windows
If you are using Windows, you might want to use the installr package:


The best way of doing this is from the RGui system. All your packages will be transferred to the new folder and the old ones will be deleted or saved (you can pick either). Then once you open RStudio again, it immediately recognizes that you are using an updated version. For me this worked like a charm.

Login / Signup to Answer the Question.