Discovering the new Digital world

09 Apr 2017

Plumbing - Updating R in few simple steps on Windows

Maintaining R on a Windows based computer is not a simple and straightforward task.

When a new version of R is published you should go through a set of steps like

Some plumbing work to be done….

A silver bullet: installr

There is a great package on CRAN, installr, that makes it possible to automate the updating of R and other supported applications. In order to be able to use it, the package needs to be installed locally on the machine.

How to install installr

Open RStudio or the R console and type

install.packages("installr", dependencies = TRUE)

#If notified that the package is not available for R version ..
#check the setting of the CRAN mirror used for downloading the
#package

How to update to the newest R version

Updating R to the newest version is as simple as using the updateR() function from the installr package.

Note!! When updating R remember to use the R Console. If using RStudio you are advised to cancel the installation and use the R console.

#load the installr library
library(installr)
updateR()

Behind the scene the function checks if a new version is available and, if available, notify and ask the user to install it (with the option to see what´s new).

If the user decides to install it, the latest version of R is downloaded and the installation is started. As part of this process the user is asked the language and where to install the new version of R.

The function helps managing the existing packages. The user is asked to copy the existing packages into the new installation and update them, and if interested in removing them. More info about what´s going on can be found using ?updateR.

When finished managing the packages the user is asked to start a new R console for the new version of R. Note that the new version of R 3.3.3 is used.

Note!! The old version and the newest version of R are both locally installed on the machine.

For completion, start RStudio and verify that the newest version of R is used (see Tools -> Global Options -> General - R Version).

And it is more than that…

installr can be used for installing other tools - start a R console and try it out installr(). More information about functions provided by the package can be found in its vignette.