How to Update R and Rstudio on Windows

Updated 11/28/2016.

In this post, I provide instructions for updating R and Rstudio on Windows.

Specifically, these instructions are intended to apply to updating R and Rstudio running on a Windows 2012 server instance at Amazon Web Services. I am assuming that the set up and provisioning of this instance are as described in my series of videos AWS Windows Instance Set Up. Such an instance is running Windows 8.

These instructions, however, should work for other Windows set-ups as well. For example, they work on my Windows notebook computer running Windows 7 as well.

The sources of information I used to figure this out are as follows:

Here are the step-by-step instructions:

  1. Shut down R and Rstudio.
  2. It is best to turn off you antivirus software. The update will probably work if you do not, but you may have to re-do things with your antivirus software disabled if it quarantines any files involved in the installation.
  3. Next run the R GUI. Do not run Rstudio. You will probably find a “shortcut” to the R GUI on your desktop. If so, you can click on that. If you do not see a link on your desktop, you will need to find the program.
  4. If you are running the R GUI, it will say RGui in the upper-left corner of the title bar of the outer window:
RguiWindow
  • In Windows 8, you can find the program by pressing the Windows key (so the Start Page appears) and then typing “R” (just the R, not the quotes). There should be links to the R GUI among the search results. If you do not see it there, then you can right click on the Start Page and then click All Apps in the bar that appears at the bottom of the screen.
  • In Windows 7, you can find the program by pressing the Start Key and then clicking on “All Programs.” Next look for the “R” folder and a link to the RGui should be in that folder.
  1. Once you have found the R GUI, run it.
  2. As of updating R on 11/28/2016, the command discussed in this step failed and was unnecessary. So go to the next step. However, if you get an error message about not being able to open the URL and about the connection changing from a secured to an unsecured connection, you might try the following command: In the R Console at the > prompt type:

setInternet2(TRUE)

  1. Next type:

if(!require(installr)) { install.packages("installr"); require(installr) }

Note that the require() function returns FALSE if the package is not available. So the above if() statement installs “installr” if it is not already available and it returns TRUE (hidden) when it is installed.

  1. Then type:

updateR()

Note: On 4/8/2016 when upgrading from R version 3.2.1 to 3.2.4, updateR() failed with an error message that begins with “Error in strsplit(version_with_dots,” and continued with more opaque information. The problem is that the installr package version that you already have installed is too old install the current version of R. The fix is to remove the installr package and reinstall it. You can remove the installr package with the command
remove.packages("installr")
Next stop the RGui with the q() command and then restart it (this is one way to unload the old version package installr so that a new version can be installed). Follow the instructions above to re-start the RGui. Then you can begin again at step 7.

  1. You will then need to answer the questions that are a part of the installation process.

I recommend: (1) Not reading the News; (2) Copying the installed packages; (3) updating the installed packages; (4) copying the Rprofile.

  1. Once the update is complete, exit the RGui by using q().
  2. Run Rstudio
  3. Go to the Help menu and the Check for Updates. If an update is available, you will be taken to the Rstudio download page.
  4. If you need the update, download it, and run the installation file. I think this is straightforward so I won’t give more detailed instructions here.
  5. The last thing you need to do is update your already installed R packages. In RStudio, go to the menu Tools and then click on “Check for package updates…” Again this process is straightforward.
  6. Once you are finished with the installation and updates, turn your antivirus software back on!

The above should take care of updating both R and Rstudio. If you run into problems or have other questions, please comment below. Based on the comments, I will correct any errors or ambiguities in the above instructions.