Oct 4, 2016

How to Upgrade R version in Windows. The easy way recommended on CRAN

Today I have found myself needing to upgrade R. Main reason was that my current version  R-3.2.1 did not support some new graphic packages. To install these new packages I needed at least a R-3.3 version.

After a bit of initial hesitation (will I lose my packages during the new installation? etc. etc.) I finally took some courage and decided to follow the official documentation on CRAN. Everything worked just fine and I have now installed the latest available R version on CRAN: at the time I write this post it´s R-3.3.1.

The upgrading process was really easy, so I thought to share it step by step. Enjoy :)

1. Check your current R version

To find out your current version, open R and it will be shown in the console. If you are using RStudio you can check you R version by clicking on Tools>Global Options... yep my current version is now R-3.3.1.

Find your R version

2. Locate your current R folder 

If you did not change the default path in your previous installation, you should be able to find the main R folder under C:\Program Files\R.

Make sure to locate your library folder too (the one containing all the packages you installed so far). It can be that either:
  1. all of your packages (the ones you have installed yourself plus the ones coming by default with the R version you originally installed) are in the library folder, under the main R folder (e.g. "C:\Program Files\R\R-3.1")
  2. or, like in my case, the packages I have manually installed are in a different folder. In my previous version they were located under this path: C:\Users\Marco\Documents\R\win-library\3.1

3. Download the latest version from CRAN

Go to CRAN website here and download the latest R version for Windows. At the day I am writing this post it's R-3.3.1.

Download R-3.3.1 Windows

4. Uninstall your current R version 

As you uninstall any other program in your Windows machine, go to Control Panel>Applications and uninstall your current R version.

5. Install the latest version on your machine

I suggest to leave the default path which should be "C:\Program Files\".

6. Copy your old packages on your new R folder

With the newer version only basic R packages will be installed. To avoid you installing again all your previous packages, go to your old library folder as per step 2 and copy your packages. Then paste them into your new library folder.

7. Make sure your packages are updated

To make sure your packages are updated to the latest version available on CRAN, you can run the following command from the R console: update.packages(checkBuilt=TRUE, ask=FALSE).

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.