All Tech Guides

Tech Guide

Install and Use RStudio

An introduction to the RStudio IDE for R, how to install RStudio Desktop on Windows, macOS, and Linux, and a beginner example using a project, a script, and a ggplot2 chart.

Development Tools Beginner Updated October 2026

Disclaimer & Important Cautions

These Tech Guides and instructions are provided in good faith as a general educational guide. Technology changes over time, and settings, software versions, installation steps, and security practices may vary by system.

I cannot guarantee that these steps will work in every environment, and I am not responsible for data loss, configuration problems, system errors, security issues, downtime, or other problems that may result from following this guide.

  • Download RStudio only from Posit's official website.
  • Use administrator privileges carefully when installing software.
  • Install add-on packages only from trusted sources such as CRAN.
  • Do not share projects that contain private or confidential data.
  • When in doubt, consult official documentation or a qualified technician.

Overview

RStudio is a free, open-source integrated development environment (IDE) for the R language, made by the company Posit (formerly named RStudio, PBC). RStudio does not replace R; it runs on top of R and gives you a much better place to work: a code editor with auto-completion, a console, a view of your data and variables, and panes for charts, files, packages, and help.

In this guide you will install RStudio Desktop, learn its layout, and complete a beginner example: creating a project, writing a script, and making a chart.

Main idea: Install R first, then RStudio. RStudio finds your R installation automatically.

Requirements

  • R already installed. See the R guide if you haven't installed it.
  • A supported operating system: Windows 11, macOS 15 or later, or a recent 64-bit Linux distribution such as Ubuntu, Debian, or Fedora.
  • Administrator privileges to install software.
  • Internet access.

Important Notes

  • If RStudio says it can't find R, R is not installed or was installed after RStudio was opened. Install R, then restart RStudio.
  • Posit also makes Positron, a newer free IDE for both R and Python. This guide covers RStudio, which is still the most widely used R editor.

RStudio Installation Instructions

Choose the tab for your operating system:

Installing RStudio Desktop

Make sure R is installed first, then click the tab above for your operating system.

The guide covers these major tasks:

  1. Download RStudio Desktop.
  2. Run the installer.
  3. Open RStudio.
  4. Confirm it found R.

Confirm the installation

When RStudio opens, the Console pane shows R's startup message with the R version number. If you are asked to choose an R installation, select the R 4.6 version you installed.

Check yourself: Type R.version.string in the Console and press Enter. RStudio reports your R version.

The RStudio Layout

RStudio is divided into four panes:

PaneDefault positionWhat it does
Source (editor)Top leftWrite and save R scripts (.R), Quarto and R Markdown documents. Appears when you open or create a file.
ConsoleBottom leftRuns R commands and shows the results. Also has Terminal and Background Jobs tabs.
Environment / HistoryTop rightLists your variables and data frames. Click a data frame to view it as a table.
Files / Plots / Packages / Help / ViewerBottom rightBrowse files, see charts, install and load packages, and read help pages.

You can change the theme and font size in Tools → Global Options → Appearance.

Beginner Example: A Project, a Script, and a Chart

Step 1: Create a project

An RStudio project keeps all the files for one piece of work together in a folder, and RStudio remembers it for you.

  1. Choose File → New Project.
  2. Choose New Directory, then New Project.
  3. Enter a Directory name such as first-r-project, choose where to create it (for example, Documents), and click Create Project.

RStudio reopens inside the project. Its name appears at the top right.

Step 2: Install a package

The ggplot2 package makes professional charts. In the Console, run:

install.packages("ggplot2")

You only need to install a package once per computer. Wait until the > prompt returns.

Step 3: Write a script

Choose File → New File → R Script. Type the following into the new script:

# first-analysis.R
library(ggplot2)

# Look at the built-in mtcars data
head(mtcars)
summary(mtcars$mpg)

# Average miles per gallon for each number of cylinders
aggregate(mpg ~ cyl, data = mtcars, FUN = mean)

# Scatter plot: weight vs. fuel economy, colored by cylinders
ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) +
  geom_point(size = 3) +
  geom_smooth(method = "lm", se = FALSE) +
  labs(title = "Heavier Cars Get Fewer Miles per Gallon",
       x = "Weight (1000 lbs)",
       y = "Miles per Gallon",
       color = "Cylinders")

Save the script with File → Save (or Ctrl + S / Cmd + S) as first-analysis.R. It appears in the Files pane.

Step 4: Run the code

  • To run one line (or a selection), put your cursor on it and press Ctrl + Enter (Windows/Linux) or Cmd + Enter (Mac).
  • To run the whole script, click Source at the top of the editor, or press Ctrl + Shift + Enter / Cmd + Shift + Enter.

Run the script line by line. Results appear in the Console, and the chart appears in the Plots pane. The aggregate line shows average mpg of about 26.7 for 4-cylinder cars, 19.7 for 6-cylinder cars, and 15.1 for 8-cylinder cars.

Step 5: Explore and export

  • In the Console, run cars_data <- mtcars. The new data frame appears in the Environment pane; click its name to view it as a sortable table.
  • In the Plots pane, click Export → Save as Image to save the chart as a PNG file.
Check yourself: The script is saved in your project folder, the chart appears in the Plots pane with three colors of points and lines, and cars_data is listed in the Environment pane.

Common Errors

  • there is no package called 'ggplot2': the package isn't installed yet. Run install.packages("ggplot2").
  • could not find function "ggplot": the package is installed but not loaded. Run library(ggplot2) first.
  • object not found: check the spelling and capitalization of the variable name.

Next Steps

  • Create a Quarto document (File → New File → Quarto Document) that mixes text, code, and charts into a report.
  • Connect RStudio to Git and GitHub with Tools → Version Control.
  • Read the RStudio User Guide.
Final Notes:
  • RStudio is an IDE that runs on top of R; install R first.
  • Use projects to keep each analysis in its own folder.
  • Write code in scripts so you can save and rerun it, and use Ctrl/Cmd + Enter to run lines.
  • Install packages once with install.packages(); load them in each script with library().
Explore more technology resources

Return to the complete collection of installation and configuration guides.

Browse All Tech Guides