← Back to Module 0: Languages & Platforms
RStudio Interface Guide
RStudio is the most popular IDE (Integrated Development Environment) for R. It's free, powerful, and designed specifically for statistical analysis and research. If you'll be using R for this course, this is where you'll spend most of your time.
What is RStudio?
RStudio is not the R language itself—it's a program that makes writing R code much easier. Think of it like this: R is the engine, and RStudio is the car with the steering wheel, dashboard, and comfortable seats. You could drive the engine directly (by running R in a terminal), but RStudio makes the experience much more pleasant.
Installing RStudio
Before installing RStudio, you need to install R itself. Here's the order:
- Install R first: Download from cran.r-project.org
- Then install RStudio: Download from posit.co/download/rstudio-desktop
RStudio needs R to function—it's just a nice interface around R. If you try to run RStudio without R installed, it won't work. Always install R first, then RStudio.
The RStudio Interface
When you first open RStudio, you'll see a window divided into four panels. Hover over each numbered region below to learn what it does:
library(tidyverse)
library(fixest)
# Load data
df <- read_csv("data.csv")
Min. 1st Qu. Median Mean 3rd Qu. Max.
15000 35000 52000 58400 75000 250000
> |
Hover over a numbered region to learn about that part of RStudio.
Essential Keyboard Shortcuts
Learning these shortcuts will dramatically speed up your workflow:
| Shortcut (Windows/Linux) | Shortcut (Mac) | Action |
|---|---|---|
Ctrl + Enter |
Cmd + Enter |
Run current line or selection |
Ctrl + Shift + Enter |
Cmd + Shift + Enter |
Run entire script |
Ctrl + L |
Cmd + L |
Clear the Console |
Tab |
Tab |
Autocomplete function/variable names |
Ctrl + Shift + C |
Cmd + Shift + C |
Comment/uncomment selected lines |
Ctrl + S |
Cmd + S |
Save current file |
Your First R Script
Let's write a simple script to make sure everything is working. In RStudio:
- Go to File > New File > R Script (or press
Ctrl+Shift+N) - Type the following code in the Source Editor:
# My first R script
# This is a comment - R ignores lines starting with #
# Print a message
print("Hello, RStudio!")
# Create some data
x <- c(1, 2, 3, 4, 5)
y <- x * 2
# Calculate the mean
mean(y)
# Create a simple plot
plot(x, y, main = "My First Plot")
- Place your cursor on the first line and press
Ctrl+Enterrepeatedly to run each line - Watch the output appear in the Console, and the plot appear in the Plots panel
Cloud Alternative: Posit Cloud
If you don't want to install anything, you can use Posit Cloud (formerly RStudio Cloud) in your browser. It's the same RStudio interface, running in the cloud.
Video Tutorial
For a visual walkthrough of the RStudio interface, I recommend this official video from Posit:
- RStudio IDE Tutorial (YouTube, ~8 min) — A quick tour of the interface
- RStudio User Guide — Official documentation