Installing R, RStudio, and tidyverse

You will do all of your visualization work in this class with the open source (and free!) programming language R. You will use RStudio as the main program to access R. Think of R as an engine and RStudio as a car dashboard—R handles all the calculations and the actual statistics, while RStudio provides a nice interface for running R code.

RStudio.cloud

R is free, but it can sometimes be a pain to install and configure. To make life easier, you can (and should!) use the free RStudio.cloud service initially, which lets you run a full instance of RStudio in your web browser. This means you won’t have to install anything on your computer to get started with R! We will have a shared class workspace in RStudio.cloud that will let you quickly copy templates for labs and problem sets.

Go to https://rstudio.cloud/ and create an account. You’ll receive a link to join the shared class workspace separately. If you don’t get this link, let me know and I will invite you.

RStudio on your computer

RStudio.cloud is convenient, but it can be slow and it is not designed to be able to handle larger datasets, more complicated analysis, or fancier graphics. Over the course of the semester, you should wean yourself off of RStudio.cloud and install all these things locally. This is also important if you want to customize fonts, since RStudio.cloud has extremely limited support for fonts other than Helvetica.

Here’s how you install all these things

Install R

First you need to install R itself (the engine).

  1. Go to the CRAN (Collective R Archive Network)It’s a goofy name, but CRAN is where most R packages—and R itself—lives.

    website: https://cran.r-project.org/
  2. Click on “Download R for XXX”, where XXX is either Mac or Windows:

    • If you use macOS, scroll down to the first .pkg file in the list of files (as of right now, it’s R-3.5.1.pkg) and download it.

    • If you use Windows, click “base” (or click on the bolded “install R for the first time” link) and download it.

  3. Double click on the downloaded file (check your Downloads folder). Click yes through all the prompts to install like any other program.

Install RStudio

Next, you need to install RStudio, the nicer graphical user interface (GUI) for R (the dashboard). Once R and RStudio are both installed, you can ignore R and only use RStudio. RStudio will use R automatically and you won’t ever have to interact with it directly.

  1. Go to the free download location on RStudio’s website: https://www.rstudio.com/products/rstudio/download/#download
  2. Select the installer that corresponds with your computer’s operating system (Windows or macOS):

  3. Double click on the downloaded file (again, check your Downloads folder). Click yes through all the prompts to install like any other program.

Double click on RStudio to run it (check your applications folder or start menu).

Install tidyverse

R packages are easy to install with RStudio. Select the packages panel, click on “Install,” type the name of the package you want to install, and press enter.

This can sometimes be tedious when you’re installing lots of packages, though. The tidyverseA universe of packages centered around tidy data, including ggplot2

for instance, consists of dozens of packages that all work together. Rather than install each individually, you can install a single magical package and get them all at the same time.

Go to the packages panel in RStudio, click on “Install,” type “tidyverse”, and press enter. You’ll see a bunch of output in the RStudio console as all the tidyverse packages are installed.

Notice also that RStudio will generate a line of code for you and run it: install.packages("tidyverse"). You can also just paste and run this instead of using the packages panel.