Installing R, RStudio, and tidyverse
You will do all of your 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.
Here’s how you install both R and RStudio Desktop on your computer. Please do the following in order.
First: Install the engine
Go to the CRAN (Collective R Archive Network) website
Click on Download R for XXX, where XXX is either Mac, Windows, or Linux:
Select your operating system below for further instructions
macOS
- Scroll down to the .pkg file that corresponds to your architecture (Intel or ARM). As of this writing, the version for each is R-4.2.1.pkg but download the most current variant
- Then download and install XQuartz
Windows
- Click base (or install R for the first time) and download it
- Then download and install Rtools
- Double click on the downloaded files (likely in your Downloads folder). Click yes through all the prompts to install like any other program.
Second: Install the dashboard Studio
Download RStudio Desktop
The website should automatically detect your operating system (macOS, Windows, Linux, etc.) and will display a big download button for it:
If not, scroll down a little to the large table and choose the version of RStudio that matches your operating system.
Double click on the downloaded file (again, check your Downloads folder if you cannot locate it). Click yes through all the prompts to install like any other program.
Double click on RStudio (not R) to run it.
Once R and RStudio Desktop are both installed, you can ignore R and only use RStudio - the nicer graphical user interface (GUI) - uses R automatically so you won’t ever have to interact with it directly sans updating the software.
Third: Install the Package
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. Unless you absolutely know it is not needed, please make sure that the Install dependencies is selected
This can sometimes be tedious when you’re installing lots of packages, though. The
tidyverse, for instance, consists of dozens of packages (e.g. including ggplot2
used for creating custom data visualizations) that all work together. Rather than install each individually, you can install a single bundle to get them all at the same time. Here is a list of all of the packages and their basic functionality1. Its absolutely fine that you may not be familiar with most of the terminology in the picture!
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. To test that the package was installed properly, please type in library(tidyverse)
as shown below.
Edited from R Coding for Data Science - 2020/21 ↩︎