r-statistics.co by Selva Prabhakaran


RStudio in 15 Minutes: The Only IDE Tour You'll Ever Need

RStudio is the standard development environment for R. It organizes your code, console, data, and plots into four panels — and once you learn how they work together, you'll write R code twice as fast.

You've installed R and RStudio. Now you're staring at a window with four panels, a dozen tabs, and a menu bar full of options. This tutorial shows you exactly what each part does, which keyboard shortcuts to memorize, and how a real R workflow moves through the interface — in about 15 minutes.

Introduction

RStudio is an IDE (Integrated Development Environment) — a single application that combines everything you need to write, run, test, and share R code. Without RStudio, you'd need separate tools for editing code, running it, viewing plots, and managing files. RStudio puts all of that in one window.

The interface has four main panels (called "panes"), and every action you take in RStudio happens in one of them. Learning the panels is like learning the cockpit of a car — once you know where everything is, you stop thinking about the tool and start thinking about the road.

Here's what we'll cover:

  • The four panels and what each one does
  • The tabs inside each panel
  • Essential keyboard shortcuts (the ones worth memorizing)
  • A real workflow walkthrough
  • How to customize the layout

The Four Panels

When you open RStudio, you see four rectangular areas arranged in a grid. Each panel has a specific job:

PanelDefault PositionPrimary Job
SourceTop-leftWrite and edit code
ConsoleBottom-leftRun code and see text output
EnvironmentTop-rightView your data and variables
OutputBottom-rightView plots, files, help, and packages

Tip: If you only see three panels (no Source panel), that's normal — the Source panel appears when you open or create a file. Press Ctrl+Shift+N (Windows/Linux) or Cmd+Shift+N (Mac) to create a new R script, and the Source panel will appear.

Let's walk through each one.

Panel 1: Source (Top-Left) — Where You Write Code

The Source panel is your code editor. This is where you write R scripts, R Markdown documents, and any other text files. Think of it as a smart notepad that understands R.

Key features:

  • Syntax highlighting — R keywords, strings, numbers, and comments are color-coded so you can read code faster
  • Auto-completion — start typing a function name and press Tab to see suggestions
  • Multiple tabs — open several files at once and switch between them
  • Line numbers — every line is numbered, making it easy to find errors
  • Code folding — collapse sections of code to focus on what matters

How to use it

  1. Create a new R script: File → New File → R Script (or Ctrl+Shift+N)
  2. Type your code in the editor
  3. To run a single line: place your cursor on it and press Ctrl+Enter (Cmd+Enter on Mac)
  4. To run multiple lines: select them and press Ctrl+Enter
  5. To run the entire script: press Ctrl+Shift+Enter (or click the Source button)

The code runs in the Console panel below, and results appear there. This is the core workflow: write in Source, run in Console.

Try this now — the code below shows what you'd type in the Source panel. Click Run to see the output:

# This is an R script — you'd save this as my_analysis.R # Each line runs when you press Ctrl+Enter # Step 1: Create some data ages <- c(25, 32, 28, 45, 37, 29, 33, 41, 26, 38) # Step 2: Basic analysis cat("Number of people:", length(ages), "\n") cat("Average age:", mean(ages), "\n") cat("Youngest:", min(ages), "\n") cat("Oldest:", max(ages), "\n") # Step 3: A quick visualization hist(ages, main = "Age Distribution", xlab = "Age", col = "steelblue", border = "white")

  

In RStudio, the text output appears in the Console (bottom-left) and the histogram appears in the Plots tab (bottom-right). Everything runs from one place.

Panel 2: Console (Bottom-Left) — Where Code Runs

The Console is R's command line. When you run code from the Source panel, it executes here. You can also type commands directly into the Console for quick, one-off calculations.

Key features:

  • The > prompt — this means R is ready for your next command
  • The + prompt — this means R is waiting for you to finish an incomplete command (usually a missing parenthesis or quote)
  • Command history — press the Up arrow to cycle through previous commands
  • Red text — errors. Read them carefully; they usually tell you exactly what went wrong
  • Blue text — warnings. Your code ran, but R wants you to know something

Console vs Source: When to use which?

Use Console for...Use Source for...
Quick calculations (2 + 2)Scripts you want to save and rerun
Testing a single lineMulti-line analyses
Exploring data (head(df), str(df))Anything you might share or revisit
Installing packagesReproducible workflows

Rule of thumb: If you might need it again, write it in Source. If it's throwaway, type it in Console.

Useful Console tricks

# Press Up Arrow to recall last command # Type the start of a previous command + Ctrl+Up to search history # Clear the console screen # Keyboard shortcut: Ctrl+L # Cancel a running command # Press Esc (or Ctrl+C on some systems) # Get help on any function ?mean help(mean)

  

Panel 3: Environment (Top-Right) — Your Data at a Glance

The Environment panel shows you every object currently in memory — variables, data frames, functions, lists, and vectors. When you create a variable in R, it appears here instantly.

Key tabs in this panel:

Environment tab

This is the most important tab. It shows:

  • Variable names and their current values
  • Data frame dimensions (rows × columns)
  • Object types (numeric, character, list, etc.)
  • A clickable arrow next to complex objects (data frames, lists) to expand and inspect them
# Run this and watch the Environment panel populate x <- 42 name <- "RStudio" scores <- c(88, 92, 75, 95, 81) my_df <- data.frame( student = c("Alice", "Bob", "Carol"), grade = c(92, 85, 78) ) # List everything in your environment ls() # Check the structure of a data frame str(my_df)

  

After running this code, your Environment panel would show: x (numeric, value 42), name (character, "RStudio"), scores (numeric vector, 5 elements), and my_df (data frame, 3 obs. of 2 variables). You can click on my_df to open it in a spreadsheet-like viewer.

History tab

Every command you've run in the current session is logged here. You can:

  • Search through past commands
  • Send to Console — double-click a command to re-run it
  • Send to Source — select commands and click "To Source" to build a script from your exploratory work

Connections tab

For connecting to databases (SQL Server, PostgreSQL, etc.). Beginners can ignore this for now.

Panel 4: Output (Bottom-Right) — Plots, Files, Help, and More

The Output panel is the most versatile. It has five tabs that serve very different purposes:

Files tab

A built-in file browser. You can navigate your project directory, open files, rename them, and delete them — all without leaving RStudio. Click on any .R file to open it in the Source panel.

Plots tab

Every plot you create in R appears here. Key features:

  • Back/Forward arrows to navigate between plots you've created in this session
  • Zoom button to see the plot larger in a new window
  • Export button to save as PNG, PDF, or copy to clipboard
# Create a plot — it will appear in the Plots tab library(ggplot2) ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl))) + geom_boxplot(show.legend = FALSE) + labs(title = "MPG by Number of Cylinders", x = "Cylinders", y = "Miles per Gallon") + scale_fill_manual(values = c("steelblue", "coral", "seagreen")) + theme_minimal()

  

In RStudio, this boxplot would appear in the Plots tab. You can click Export → Save as Image to save it, or Export → Copy to Clipboard to paste it into a document.

Packages tab

Lists all installed R packages with checkboxes to load/unload them. You can also:

  • Install new packages (click the Install button)
  • Update outdated packages (click Update)
  • Click a package name to open its documentation

Help tab

R's built-in help system. When you type ?function_name in the Console, the help page appears here. Help pages follow a consistent structure:

  • Description — what the function does
  • Usage — the function signature with all arguments
  • Arguments — what each argument means
  • Value — what the function returns
  • Examples — runnable code examples (the most useful part!)
# Try these — each opens help in the Help tab ?mean # Help for the mean() function ?lm # Help for linear regression ?ggplot # Help for ggplot2's main function # Search for a topic (when you don't know the exact function name) ??regression # Searches all help files for "regression"

  

Viewer tab

Displays web content — Shiny apps, HTML widgets, R Markdown previews. Beginners won't use this much initially.

Essential Keyboard Shortcuts

These are the shortcuts worth memorizing. They'll save you thousands of mouse clicks over time.

The Must-Know Five

ShortcutWindows/LinuxMacWhat it does
Run current lineCtrl+EnterCmd+EnterRuns the line where your cursor is
New scriptCtrl+Shift+NCmd+Shift+NCreates a new R script
Assignment operatorAlt+ -Option+ -Types <- (the R assignment arrow)
Pipe operatorCtrl+Shift+MCmd+Shift+MTypes |> (the pipe)
Comment/uncommentCtrl+Shift+CCmd+Shift+CToggles # comment on selected lines

Navigation

ShortcutWindows/LinuxMacWhat it does
Go to ConsoleCtrl+2Ctrl+2Moves cursor to Console
Go to SourceCtrl+1Ctrl+1Moves cursor to Source editor
Clear ConsoleCtrl+LCtrl+LClears the Console screen
Find in fileCtrl+FCmd+FOpens find/replace dialog
Find in filesCtrl+Shift+FCmd+Shift+FSearches across all project files

Running Code

ShortcutWindows/LinuxMacWhat it does
Run selectionCtrl+EnterCmd+EnterRuns selected code or current line
Run entire scriptCtrl+Shift+EnterCmd+Shift+EnterRuns the whole script
Run from start to cursorCtrl+Alt+BCmd+Option+BRuns everything above current line
Cancel executionEscEscStops running code

See All Shortcuts

Press Alt+Shift+K (Windows/Linux) or Option+Shift+K (Mac) to see the complete list of keyboard shortcuts in RStudio. There are over 100, but the 10-15 above cover 90% of daily use.

A Real Workflow: From Data to Insight

Let's walk through a typical R workflow to see how the panels work together. This is what a real analysis session looks like:

# STEP 1: Load packages (type in Source, run with Ctrl+Enter) library(dplyr) library(ggplot2) # STEP 2: Load data — check the Environment panel to see it appear data <- mtcars cat("Dataset loaded:", nrow(data), "cars,", ncol(data), "variables\n") # STEP 3: Explore — output appears in Console head(data)

  

After running the above, your Environment panel shows data (32 obs. of 11 variables). The Console shows the first 6 rows. Now continue the analysis:

# STEP 4: Analyze — group and summarize summary_table <- data |> mutate(car_name = rownames(data)) |> group_by(cyl) |> summarise( count = n(), avg_mpg = round(mean(mpg), 1), avg_hp = round(mean(hp), 0), best_car = car_name[which.max(mpg)] ) # View the result — appears in Console summary_table

  

The Environment panel now also shows summary_table (3 obs. of 5 variables). Click on it to see it in a spreadsheet view.

# STEP 5: Visualize — plot appears in the Plots tab ggplot(data, aes(x = hp, y = mpg, color = factor(cyl), size = wt)) + geom_point(alpha = 0.7) + labs(title = "Horsepower vs Fuel Efficiency", subtitle = "Size = car weight; Color = cylinders", x = "Horsepower", y = "Miles per Gallon", color = "Cylinders", size = "Weight (1000 lbs)") + theme_minimal()

  

That's the flow: Source → Console → Environment → Plots. Write code in Source, run it to Console, watch variables appear in Environment, see visualizations in Plots.

Customizing Your Layout

RStudio lets you rearrange everything. Go to Tools → Global Options → Pane Layout to:

  • Move panels — swap which panel is in which corner
  • Choose tabs — decide which tabs appear in which panel
  • Dual Source columns — split the Source panel into two side-by-side editors (great for comparing files)

Recommended layout adjustments

  1. Maximize Source when writing: Press Ctrl+Shift+1 to fill the screen with the Source editor. Press it again to restore the 4-panel layout.
  2. Maximize Console when debugging: Press Ctrl+Shift+2 to focus on the Console.
  3. Change the theme: Go to Tools → Global Options → Appearance and try different editor themes. Dark themes like Tomorrow Night reduce eye strain during long sessions.
  4. Increase font size: In the same Appearance settings, bump the font size to 12-14pt if the default feels small.

Practice Exercises

Exercise 1: Navigate the Panels

Open RStudio and try these keyboard shortcuts. After each one, note which panel your cursor is in:

# Exercise: Practice these shortcuts in RStudio # 1. Press Ctrl+1 — where is your cursor now? # 2. Press Ctrl+2 — where is your cursor now? # 3. Press Ctrl+Shift+N — what happened? # 4. Press Alt+- (or Option+- on Mac) — what was typed? # 5. Type: x <- 42 and press Ctrl+Enter — check all 4 panels # Write your observations below:

  
Click to reveal solution
  1. Ctrl+1 → Cursor moves to Source panel (top-left)
  2. Ctrl+2 → Cursor moves to Console panel (bottom-left)
  3. Ctrl+Shift+N → A new R script tab opens in the Source panel
  4. Alt+- → The assignment operator <- was typed
  5. Ctrl+Enter → The line x <- 42 runs. Console shows > x <- 42. Environment shows x with value 42.

Explanation: These five shortcuts form the backbone of RStudio navigation. Ctrl+1 and Ctrl+2 let you jump between writing and running code without touching the mouse.

Exercise 2: Build a Mini Analysis

Write a complete mini-analysis using the RStudio workflow. Create data, analyze it, and plot it:

# Exercise: Complete this analysis in RStudio # 1. Create a data frame with 5 students and their scores # 2. Calculate the mean and max score # 3. Create a barplot of the scores # Hint: Use barplot() or ggplot2 # Write your code below:

  
Click to reveal solution
# Solution: Mini student analysis students <- data.frame( name = c("Alice", "Bob", "Carol", "David", "Eve"), score = c(92, 85, 78, 95, 88) ) cat("Mean score:", mean(students$score), "\n") cat("Top scorer:", students$name[which.max(students$score)], "with", max(students$score), "\n") barplot(students$score, names.arg = students$name, col = "steelblue", main = "Student Scores", ylab = "Score", ylim = c(0, 100))

  

Explanation: This exercise uses all four panels — you write in Source, output appears in Console, students appears in Environment, and the barplot appears in Plots.

Exercise 3: Use the Help System

# Exercise: Use RStudio's help system # 1. Find help for the sort() function — what does decreasing do? # 2. Search for functions related to "correlation" # 3. Find an example of how to use cor() # Hint: Use ? and ?? # Write your code below:

  
Click to reveal solution
# Solution ?sort # Opens help — the 'decreasing' argument sorts high to low ??correlation # Searches for "correlation" across all help files ?cor # Help for cor() — scroll to Examples section # Test it: x <- c(1, 5, 3, 2, 4) sort(x) # Default: ascending sort(x, decreasing = TRUE) # Descending # Correlation example from help: cor(mtcars$mpg, mtcars$wt) # Negative correlation: heavier cars get worse MPG

  

Explanation: The ? operator opens help for a specific function. The ?? operator searches across all packages. The Examples section at the bottom of help pages is the fastest way to learn how a function works.

Summary

PanelPositionWhat it doesKey shortcut
SourceTop-leftWrite and edit codeCtrl+1 to focus
ConsoleBottom-leftRun code, see text outputCtrl+2 to focus
EnvironmentTop-rightView variables and dataClick to inspect
OutputBottom-rightPlots, files, help, packagesCtrl+3 to focus

The core workflow: Write in Source → Run with Ctrl+Enter → See results in Console + Environment + Plots.

The five shortcuts to memorize first: Ctrl+Enter (run), Ctrl+Shift+N (new script), Alt+- (assignment), Ctrl+Shift+M (pipe), Ctrl+Shift+C (comment).

FAQ

Can I rearrange the panels?

Yes. Go to Tools → Global Options → Pane Layout. You can put any panel in any quadrant. Some people prefer the Console on the right side, or the Source panel at full width on top with everything else below.

What's the difference between the Console and the Terminal?

The Console runs R code. The Terminal (accessible via the Terminal tab next to Console) runs system commands — bash on Mac/Linux, PowerShell on Windows. Use the Terminal for git commands, file management, or running Python scripts.

How do I open multiple R scripts at once?

Just open multiple files — each one gets its own tab in the Source panel. You can also split the Source panel: View → Panes → Show Dual Source Columns (or drag a tab to the right side of the Source panel).

Where do I find the RStudio cheat sheet?

Go to Help → Cheat Sheets → RStudio IDE Cheat Sheet. This opens a 2-page PDF with every panel, button, and shortcut documented visually. Print it and keep it next to your keyboard for the first few weeks.

Can I use RStudio for Python too?

Yes, since RStudio 2023+. You can create Python scripts, run them in a Python REPL, and even mix R and Python in Quarto documents using the reticulate package. However, if Python is your primary language, VS Code or Positron might be better choices.

What's Next?

Now that you know your way around RStudio, it's time to start writing R code:

  1. R Syntax 101 — write your first working R script with variables, operators, and functions
  2. R Data Types — understand the six types every R variable belongs to
  3. R Vectors — master the most fundamental data structure in R

Each tutorial builds on the previous one, and all include interactive code blocks you can run right in your browser.