New release of R – all packages gone?

A brand new release of R is out, you install it using the convenient installer and bam! you are up to date again. And, as a special treat you might find yourself without the packages you had previously installed. At least, that is what happened to me. A simple way to get the packages installed again? Use this line of code in your R console:

install.packages( as.character( installed.packages( "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/" ))$Package))

This will automatically install all the packages that were installed for the previous release (which in this case was R 3.1, which you can see in the path). Depending on what version number your previous release had you will have to change the version number in the path accordingly.

Nah, is that a time saver?

Coming back to the head line: your packages are not gone at all, it is just that your new version of R is looking for packages in a new folder. See it as an advantage, if you ever have to deal with a package that is only running say with R 3.0 then you can go back to the 3.0 directory with all the other packages that were functional at that time as well.

And as a side note, a quick google search will bring up similar pieces of code thanks to the helpful bloggers Randy Zwitch and rmkrug.

One thought on “New release of R – all packages gone?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s