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.
RStudio
Here’s how you install both R and RStudio on your computer. Please do the following in order.
Install R
First you need to install R itself (the engine).
- Go to the CRAN (Collective R Archive Network) website:
-
Click on “Download R for
XXX
”, whereXXX
is either Mac, Windows, or Linux:- If you use macOS
- scroll down to the
.pkg
file that corresponds to your architecture (Intel or ARM). As of this writing, the version for each is isR-4.1.1.pkg
but download the most current variant - download and install
XQuartz
- If you use Windows
- click
base
(or click on the bolded “install R for the first time” link) and download it - download and install
Rtools
-
Double click on the downloaded files (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.
-
Download RStudio
-
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). 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.
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.