Installing R and RStudio
R and RStudio are two separate pieces of software that work together: R is the actual programming language and execution engine that runs your code, while RStudio is an integrated development environment (IDE) — a graphical application made by Posit that wraps around R to give you a code editor, console, plot viewer, and package manager in one window. You must install R first, because RStudio itself does not contain a language runtime; it simply launches and communicates with whichever R installation it finds on your system.
Cricket analogy: R is like the actual match being played on the pitch, while RStudio is like the broadcast studio with replays, Snickometer, and Hawk-Eye overlays — the match (R) has to exist before the broadcast (RStudio) can show anything.
Step 1: Installing R from CRAN
R is downloaded from CRAN (cran.r-project.org), which provides platform-specific installers: an .exe installer for Windows, a .pkg installer for macOS, and repository instructions (apt, dnf, or building from source) for Linux distributions. CRAN maintains regional mirrors around the world, so most first-time users should select the '0-Cloud' mirror, which automatically redirects to a nearby, up-to-date server rather than requiring you to pick a specific country.
Cricket analogy: It's like downloading the official ICC scoring app from your regional app store rather than an unofficial third-party clone — CRAN's official installers for Windows, macOS, and Linux are the trusted 'official app store' for R.
Step 2: Installing RStudio Desktop
After R is installed, download RStudio Desktop from posit.co/downloads; the free 'Open Source Edition' is sufficient for virtually all learning and professional individual use, while paid editions add enterprise features like centralized license management. During installation, RStudio automatically detects your existing R installation, so as long as R was installed first and is on a standard path, you typically don't need to configure anything manually before RStudio opens with a working console.
Cricket analogy: It's like installing the official broadcast overlay software after the stadium's camera rig (R) is already wired in — RStudio auto-detects the existing R 'camera feed' with no manual configuration needed.
Touring the RStudio IDE
RStudio's default layout has four panes: the Source pane (top-left) for writing and editing .R script files, the Console pane (bottom-left) where code actually executes and results print immediately, the Environment/History pane (top-right) listing every variable currently in memory, and the Files/Plots/Packages/Help pane (bottom-right) for browsing your project directory, viewing generated charts, and reading function documentation. You can run a single line from the Source pane by pressing Ctrl+Enter (Cmd+Return on macOS), which sends that line to the Console without needing to retype it.
Cricket analogy: It's like a broadcast control room with four monitors: the live camera feed (Source), the commentary box (Console), the scoreboard (Environment), and the replay/stats screen (Plots/Help) — each pane has one clear job.
# Confirm R is installed and check its version
R.version.string
#> "R version 4.4.1 (2024-06-14)"
# Install a package from CRAN (only needs to be done once)
install.packages("ggplot2")
# Load the package into the current session (needed every session)
library(ggplot2)
# Check where RStudio thinks your R installation lives
R.home()If you don't want to install anything locally, Posit Cloud (posit.cloud) gives you a full RStudio environment in the browser with a free tier — useful for trying R on a school Chromebook or a locked-down work laptop before committing to a local install.
Updating RStudio does NOT update R, and vice versa — they are versioned and updated completely independently. If a script suddenly needs a newer R feature, check Tools > Global Options > General in RStudio to see which R version it's actually pointing to, and update R separately from CRAN if needed.
- R is the language/engine; RStudio is the IDE built around it — install R first, then RStudio.
- Download R from cran.r-project.org, selecting the '0-Cloud' mirror for an automatic nearby server.
- Download RStudio Desktop (free Open Source Edition) from posit.co/downloads.
- RStudio auto-detects an existing R installation without manual configuration in most cases.
- RStudio's four default panes are Source, Console, Environment/History, and Files/Plots/Packages/Help.
- Run a line of code from the Source pane with Ctrl+Enter (Cmd+Return on macOS).
- R and RStudio update independently of each other — check Tools > Global Options to confirm which R version RStudio is using.
Practice what you learned
1. What is the relationship between R and RStudio?
2. Where should you download R from?
3. Which RStudio pane shows every variable currently loaded in your session?
4. What keyboard shortcut runs the current line from the Source pane on Windows?
5. Why might updating RStudio not fix a script that requires a newer R feature?
Was this page helpful?
You May Also Like
What Is R?
An introduction to R as a statistical programming language: its history, design philosophy, real-world applications, and how it compares to other data tools.
Your First R Script
How to write, structure, and run a complete R script covering variables, a custom function, control flow, and output, both inside RStudio and from the command line.
R Variables and Data Types
How to create variables in R with the assignment operator, the core atomic data types, special values like NA and NULL, and how type coercion works.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics