3 Getting and setting up RStudio

Written by Annie Collins and last updated on 7 October 2021.

3.1 Introduction

In this lesson, you will learn how to:

  • download R and RStudio Desktop.

3.2 R vs. RStudio

Before we get started, it is important to understand the different components that make coding with R possible.

R is different from RStudio and you need to download both. R refers to the programming language we’re using, and RStudio is the desktop application (in technical language, the IDE or “integrated development environment”) that makes it possible to read, write, and view the output of our R code. You can technically use R without RStudio, but you cannot use RStudio without R.

University of Toronto Professor Liza Bolton has a wonderful analogy: if R is like a car engine, RStudio is like the car. While it’s possible to use a car engine directly, most of us find it helpful to use a car. So we’re going to use RStudio to interface with R.

3.3 Getting R

Your first step is to download R. It can be downloaded for free from the R website: https://www.r-project.org. It’s not the most user-friendly website ever built, so I’ve taken a series of screenshots to help explain things. First you need to click download R.

Then you need to pick a mirror. This is done for largely historical reasons - when the internet was slow it could be faster to get it from a source that was closer. These days it doesn’t really matter, and the web interface (shown below) generally looks the same across all mirrors. Just pick a version from a place that you’re familiar with.

For anyone near the University of Toronto, the university hosts its own mirror: https://utstat.toronto.edu/cran/.

If you don’t know what to pick, then you can use the one that I always use - https://cran.csiro.au/.

You then need to download the appropriate version for you depending on whether you’ve got Windows, Mac, or Linux. I’ll pick Mac, but the next page looks very similar for all three.

At this point, you can click to do the actual download. This will differ depending on exactly when you are following these instructions, but you’re looking for something like R-4.0.4.pkg.

After that downloads you can install it on your computer like any other application.

3.4 Getting RStudio

To get started, visit the RStudio website: https://rstudio.com. Then click on download.

You want RStudio Desktop, which is free. Click download and it should try to guess your operating system and provide the correction option for your set-up. In my case, this is Mac, so I can click Download, and then install it like any other application.

3.5 Next Steps

Congratulations! You are now ready to start running R code in RStudio Desktop. In the next lesson, you will learn how to navigate RStudio and some of its key features that will come in handy once you start programming in R.