R and RStudio: Complete Installation Guide

Install the latest R from CRAN and RStudio from Posit on an Ubuntu-based Linux desktop, upgrade from old versions, and clean up leftover R package libraries.

Beginner Verified Working Updated 6 min read Tested on Linux Mint 22.3 Cinnamon (Ubuntu 24.04 Noble base); also tested on Zorin OS 18.1 Pro Hardware Lenovo ThinkPad L14 Gen 2 (Intel i5-1135G7, 16GB RAM, Intel Iris Xe, 1366x768)

What This Guide Achieves

By the end of this guide you will have:

FeatureStatus
Latest R version from CRAN (R 4.6.x) installedYes
R development tools (compilers, build deps) installedYes
Old R package libraries cleaned after version upgradeYes
RStudio IDE installed from official Posit .debYes
R and RStudio verified workingYes
Complete removal script if neededYes

The Problem (Windows User Perspective)

On Windows, you download an .exe, double-click, and you’re done. On Linux, if you run sudo apt install r-base, Ubuntu’s default repositories give you an outdated version (R 4.3.3 on Ubuntu 24.04 Noble). This version is too old for modern R packages and may break your workflow.

The fix: add the official CRAN repository, which always serves the latest R release. Then install RStudio from Posit’s official .deb.


System Information (Tested Setups)

ComponentDetails
MachineLenovo ThinkPad L14 Gen 2
OS (Primary)Linux Mint 22.3 Cinnamon (Ubuntu 24.04 Noble base)
OS (Secondary)Zorin OS 18.1 Pro (Ubuntu 24.04 Noble base)
R version4.6.0 (2026-04-24) — “Because it was There”
RStudio version2026.04.0+526
CRAN mirrorcloud.r-project.org

Part 1 — Install the Latest R from CRAN

Why the default repos give you an old version

Ubuntu’s universe repository freezes package versions at distro release time. For Ubuntu 24.04 Noble, that means R 4.3.3 — released in February 2024. CRAN serves R 4.6.x, which includes bug fixes, performance improvements, and compatibility with current packages.

Step 1 — Install dependencies

sudo apt update
sudo apt install --no-install-recommends software-properties-common dirmngr wget
PackagePurpose
software-properties-commonProvides add-apt-repository
dirmngrGPG key management for secure package verification
wgetDownloads files, including GPG keys

Step 2 — Add the CRAN GPG signing key

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
  sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg

Step 3 — Add the CRAN repository

Mint 22.x and Zorin OS 18.x are both based on Ubuntu Noble. Use the noble-cran40/ suite:

echo "deb [signed-by=/usr/share/keyrings/cran.gpg] https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" | \
  sudo tee /etc/apt/sources.list.d/cran.list

For other Ubuntu versions: Replace noble-cran40/ with jammy-cran40/ (22.04), focal-cran40/ (20.04), etc. Run lsb_release -cs to see your codename.

Step 4 — Install R and development packages

sudo apt install r-base r-base-dev

Installing r-base-dev alongside r-base is strongly recommended — it includes the C/C++/Fortran compilers (build-essential, gfortran, etc.) that many R packages need to compile from source.

Step 5 — Verify

R --version
# Should print: R version 4.6.x ... "Because it was There"

Note: Use two dashes — R --version not R -version. A single dash outputs an unknown option warning.

To launch the R console: type R and press Enter. To exit, type q().


Part 2 — Upgrade R When a Newer Version Exists

If you already have R installed from the default repos (4.3.3) and want to upgrade to the latest CRAN version:

Step 1 — Add the CRAN repository (if not already added)

If you haven’t already added the CRAN repository, add the GPG key and repo:

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
  sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg
echo "deb [signed-by=/usr/share/keyrings/cran.gpg] https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" | \
  sudo tee /etc/apt/sources.list.d/cran.list

Step 2 — Update the package list

sudo apt update

Step 3 — Upgrade R packages only

sudo apt install --only-upgrade r-base r-base-core r-base-dev

This pulls the newer versions from CRAN without touching other packages.

Step 4 — Verify

R --version
# Should now show R version 4.6.x

Part 3 — Clean Up Old R Package Libraries

When you upgrade R to a new major or minor version (e.g., 4.3 → 4.6), the system overwrites core files but leaves behind your user-installed R packages from the old version. These packages are incompatible with the new R and waste disk space.

Check what libraries exist

ls ~/R/x86_64-pc-linux-gnu-library/
# Example output:
# 4.3
# 4.6

Remove the old library folder

rm -rf ~/R/x86_64-pc-linux-gnu-library/4.3

Only remove folders for R versions you no longer use. Keep the current version (e.g., 4.6).

Clean up orphaned system-level packages

sudo apt autoremove --purge

This removes any system packages that were automatically installed as dependencies but are no longer needed.

After cleanup: You must reinstall your R packages inside the new version. Launch R and run install.packages("package_name") for each package you need.


Part 4 — Install RStudio

RStudio is a separate application from R itself. It provides the familiar IDE with the console, script editor, environment viewer, and plot pane.

Download and install from Posit

# Download the latest RStudio .deb from Posit
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-latest-amd64.deb -O /tmp/rstudio-latest-amd64.deb

# Install
sudo apt install /tmp/rstudio-latest-amd64.deb

# Clean up the downloaded file
rm /tmp/rstudio-latest-amd64.deb

Version installed on the tested setup: 2026.04.0+526

Note: The URL uses jammy in the path, but the same .deb works on Noble-based distros (Mint 22.x, Zorin OS 18.x). Posit builds a single amd64 package for all Ubuntu 22.04+ systems.

Verify

rstudio --version
# Should print: 2026.04.0+526

which rstudio
# Should print: /usr/bin/rstudio

RStudio now appears in your application menu. Launch it, and it will automatically detect your R installation.

Automatic updates

The .deb install registers Posit’s repository, so RStudio will update alongside your system packages:

sudo apt update && sudo apt upgrade

Part 5 — Complete Removal

Remove R

sudo apt remove --purge r-base r-base-core r-base-dev r-recommended
sudo apt autoremove --purge

# Remove CRAN repository and key
sudo rm /etc/apt/sources.list.d/cran.list
sudo rm /usr/share/keyrings/cran.gpg

Remove RStudio

sudo apt remove --purge rstudio
sudo apt autoremove --purge

Clean up personal R files (optional — removes all R packages and settings)

rm -rf ~/R
rm -rf ~/.config/R
rm -rf ~/.local/share/rstudio
rm -rf ~/.config/rstudio

Quick Verification Checklist

# 1. R binary exists and reports correct version
R --version | head -1
# Expected: R version 4.6.x ...

# 2. R development tools present
dpkg -l r-base-dev | tail -1
# Expected: ii  r-base-dev ...

# 3. R starts interactively
R -q -e "print('Hello from R')"
# Expected: [1] "Hello from R"

# 4. RStudio installed
which rstudio
# Expected: /usr/bin/rstudio

# 5. CRAN repository configured
grep -r "cran" /etc/apt/sources.list /etc/apt/sources.list.d/
# Should show the cloud.r-project.org entry


Tested on Linux Mint 22.3 Cinnamon (also Zorin OS 18.1 Pro) · ThinkPad L14 Gen 2 (i5-1135G7, 16GB, Iris Xe) · May 2026 This guide is free to share, adapt, and republish with attribution.

Discussion