Although R and RStudio will be available in the lab, you will likely want to install R and RStudio on your own personal laptop, desktop, or both. Below are installation instructions for R and RStudio.

Install R (may require administrator privileges)

Please go to and click on download R. You will be asked to select a CRAN mirror. I select for obvious reasons. In the download and install R section, click on the correct link depending on your operating system: Linux, (Mac) OS X, or Windows.


Click on base and then the link to Download R X.X.X for Windows (where the X will be numbers representing the current version of R). Install this program like any other program on Windows using all the defaults.

(Mac) OS X

Click on the appropriate .pkg file depending on which version of Mac OS X you are using.

Install this program like any other program on OS X using all the defaults.


If you are using Linux, then I trust you know what you are doing. You can install R from source or you can use a package manager.

Install RStudio (may require administrator privileges)

The installation of RStudio is optional, but highly recommended. It provides an improved interface to R and has projects which help to quickly switch between (oddly enough) projects. Go to and choose the correct platform under Installers for ALL Platforms. Install like any other program.

Now, whenever you want to run R, just run RStudio.

Install packages

Install all necessary packages

The last thing you need to do is to install all the packages that are necessary for this course. To do so, run the following command in the Console in RStudio.

install.packages(c("tidyverse","gridExtra")) # you will need to uncomment this line in the script

This process will take about a minute (depending on your internet connection).


The base installation of R provides access to many graphical and statistical methods. But a great many more are available as R packages. The main repository for R packages is the Comprehensive R Archive Network (CRAN).

To install a package from CRAN, you can use the function install.packages(). For example, to install the tidyverse package (which you definitely want to do) use


Packages only need to be installed once (until you update R) so you will only have to run install.packages() once for each package you need.

By convention, any packages that are needed in a script are included at the top of the script using the library() function. For example,


If you try to run one of the commands above when you don’t have the package installed, you will see an error, e.g. 

## Error in library("notarealpackage"): there is no package called 'notarealpackage'

If you get this error, you should run install.packages() using the package name as the argument to install the package.