Lesson 0 · Getting started
Set up
Install R and RStudio, and make a folder for the course.
Two programs
RThe engine
Does the work: reads data, runs statistics, draws charts.
RStudioThe dashboard
The window you work in. It runs R for you.
You need both. Install R first, because RStudio needs it.
Both are free.
Step 1: Install R
- Go to https://cran.r-project.org.
- Click Download R for Windows or Download R for macOS.
- Windows: click base, then the top link (Download R-4.x.x for Windows). Mac: pick arm64 for Apple M1/M2/M3/M4 chips, x86_64 for Intel. (Apple menu > About This Mac shows your chip.)
- Open the downloaded file and click Next / Continue until it finishes.
Step 2: Install RStudio
- Go to https://posit.co/download/rstudio-desktop/.
- Click Download RStudio Desktop.
- Windows: run the file. Mac: drag RStudio into Applications.
From now on, always open RStudio, not R.
Step 3: Check it works
Open RStudio. Click in the Console panel (left), type this and press Enter:
1 + 1Output
[1] 2
You see [1] 2? You're ready.
Step 4: Make a course folder
An RStudio Project is a folder that RStudio treats as home. Files you save go there, and R looks there for data.
- File > New Project... > New Directory > New Project
- Name it
learn-r, choose where to save it (e.g. Documents), click Create Project. - In the Files tab (bottom right), click New Folder and make a folder called
data.
learn-r/ ├── learn-r.Rproj ← double-click to open the project └── data/ ← put data files here
Each lesson tells you which data file it needs. Save it in data.
Next time, open the project with File > Open Project... or double-click learn-r.Rproj.