1 Objective

  • Download, install, and set up R and RStudio on your local machine

2 Materials

View the slides for this section here.

3 R (a quick background)

When people decide to begin using R, it can be confusing to know where to start. Googling “how can I learn R?” will return a lot of results, but it can quickly feel like you’re drinking water from a fire-hose. Like most things, knowing the correct terminology can help you sift through the resources to find what you’re looking for.

We’re going to clear up some of the terms and definitions so the R programming landscape is a little less overwhelming:

  1. R - an open-source software programming language for statistical analysis and graphics (compared to proprietary software like SPSS or SAS)
  2. the R console - a command line interface for entering and executing R code.
  3. .R script files - plain text files containing R code that computers can run.
  4. RStudio - an Integrated Development Environment, or IDE for writing R code, connecting to databases, building graphics, websites, software packages, and applications.

4 Installation

Depending on what kind of computer you have, these instructions will be a little different. The two sections below describe how to install R and RStudio on Mac and Windows machines. An alternative to downloading and installing R and RStudio is using RStudio.Cloud, which operates entirely in your browser. You’ll need to sign up for a free RStudio.Cloud account using a Github account (also free!).

4.1 Installing R on Mac

These steps cover how to install R and RStudio on a Mac. The technical details on the operating system and machine are listed below,

MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
macOS Big Sur
  Version: 11.2.3 (20D91)
Model Name: MacBook Pro
  Model Identifier: MacBookPro14,2
  Graphics: Intel Iris Plus Graphics 650 1536 MB
  Processor Name:   Dual-Core Intel Core i5
  Processor Speed:  3.1 GHz
  Number of Processors: 1
  Total Number of Cores:    2
  L2 Cache (per Core):  256 KB
  L3 Cache: 4 MB
  Hyper-Threading Technology:   Enabled
  Memory:   16 GB
  System Firmware Version:  429.80.1.0.0
  SMC Version (system): 2.44f6

4.1.1 Download R

Navigate to CRAN, the The Comprehensive R Archive Network.

Click on the Download R for (Mac) OS X.

Download the R package:

Download the R installer package into your Applications folder.

4.1.2 Download RStudio

Navigate to RStudio downloads for Macs

Download the RStudio .dmg into your Applications folder.

4.1.3 Install Xcode

You’ll need to install Xcode to compile R packages, which you can find in the Mac App Store.

Open the App Store on your local machine and click on the ‘Develop’ tab. Click on the ‘Get’ icon (mine says ‘open’ because I already Xcode installed).

Follow the instructions to install Xcode just like you would any other application on your Mac.

4.1.4 Install R

Open your Applications folder and click on the R package installer.

This will open the installer package, click on ‘Continue’ until you’re asked to ‘Agree’

Click ‘Agree’

All the package installer to install R on your machine.

Wait for R to finishing installing…

Click ‘Close’ when the application is installed.

4.1.5 Install RStudio

Open your Applications folder and click on the RStudio .dmg installer.

Drag and drop the ‘RStudio.app’ icon into the ‘Applications’ folder.

Wait for the application to finishing copying…

Double-click on the new ‘RStudio.App’ icon.

We’re sure–click ‘Open’

Take a look at the RStudio IDE!

4.2 Installing R on Windows

These steps cover how to install R and RStudio on a Windows machine. The technical details on the operating system and machine are listed below.

4.2.1 Download R

Head to CRAN.

Click on download R for Windows.

4.2.2 Download RStudio

Navigate to RStudio downloads for Windows

Download the RStudio .exe file

4.2.3 Download Rtools

Head over to Rtools

Download the rtools40v2-x86_64.exe file.

4.2.4 Install R

The steps below outline installing R version 4.1.0 on Windows. The installation steps might look sightly different on your machine. Ask me if you get stuck.

4.2.5 Install Rtools

4.2.6 Install RStudio (windows)

These steps walk you through how to install RStudio on your windows machine.

4.2.6.1 Download .exe file

Download the windows version of RStudio here. You should see the .exe file in your downloads folder (or wherever you downloaded it).

4.2.6.2 Launch Wizard

Double click on the .exe file and launch the install Wizard:

4.2.6.3 Choose install location

This should be your C:\Program Files folder:

4.2.6.4 Choose start menu folder

The default is fine here:

4.2.6.5 Installation (process)

You should see the progress bar running:

4.2.6.6 Finish

Click Finish to exit the installation Wizard:

4.2.6.7 Verify

Check if there is an RStudio icon on your desktop. Double-click the icon to open it. If you don’t see the icon, click on the ‘Start’ button at the bottom left of the screen and search for ‘RStudio’ (then click on the RStudio icon to open it).