If your R version or packages are old, you might get errors or find that the code required to run some examples is different from the one provided.

Recall that R is the underlying programming language, while RStudio is just a wrapper around R providing a nicer user interface (text editor, file explorer and graphical window). Updating RStudio (the interface) will not update the R programming language which runs your code.

You can find a video explaining how to update R, as well as step-by-step instructions below.

1. Check the version of R that you have

Check that your R version is up-to-date by typing into the R console:

version

After pressing Enter, you should see something like this:

platform       <this will be different for each of you>     
arch           <this will be different for each of you>                  
os             <this will be different for each of you>     
system         <this will be different for each of you>        
status                                     
major          4                           
minor          0.2                         
[and more lines which you can ignore...]

Please check here: https://www.r-project.org/ to see what the most recent version is. If you have a different number for “major” than the most recent, it may well be time for an update.

2. Update R

Windows

Type the following into R pressing Enter to run the code:

install.packages("installr")
installr::updateR()

Apple Mac

3. Update the R packages

In R, type the following and press Enter:

options(pkgType = "binary")
update.packages(ask = FALSE)