R is a programming language designed for statistical computing, data analysis, and visualization. As a result, researchers, data scientists, and analysts use R for everything from academic studies and bioinformatics to machine learning pipelines and financial modeling. Installing R on Linux Mint takes just a few minutes using the official CRAN repository, which ensures you always have access to the latest stable release with security updates.
This guide walks through adding the CRAN repository to Linux Mint, installing R core with optional development tools, and managing packages from the Comprehensive R Archive Network (CRAN). By following these steps, you will learn repository configuration, package management strategies for both console and system-wide installations, and how to resolve common issues.
Choose Your R Installation Method
Linux Mint users can choose between two installation approaches: use the official CRAN repository for the latest stable R, or rely on the r2u binary mirror for thousands of pre-built packages without compilation. Consider your support expectations and maintenance time before selecting an option.
| Method | Version / Channel | Stability | Best For |
|---|---|---|---|
| CRAN APT Repository | Latest upstream R release for supported Ubuntu LTS bases | Fully tested, signed packages directly from CRAN maintainers | Default choice for most desktops that need predictable updates |
| r2u (CRAN-Apt) | Daily-built CRAN and BioConductor packages as Debian binaries | High velocity with automatic dependency resolution through APT | Data science workflows that need thousands of CRAN packages without compiling from source |
For most users, the CRAN APT repository is recommended because it provides the latest stable R release with automatic security updates through the package manager.
Linux Mint is built on Ubuntu LTS releases. This guide covers Linux Mint 22.x (based on Ubuntu 24.04 Noble) and Linux Mint 21.x (based on Ubuntu 22.04 Jammy). Because Mint uses Ubuntu repositories for R packages, the CRAN repository uses Ubuntu codenames rather than Mint codenames. Commands work identically on both supported Mint series.
The following table maps Linux Mint versions to their Ubuntu base, which determines which repository codename to use:
| Linux Mint Version | Mint Codename | Ubuntu Base | Ubuntu Codename |
|---|---|---|---|
| Linux Mint 22.x | Wilma, Xia | Ubuntu 24.04 LTS | noble |
| Linux Mint 21.x | Vanessa, Vera, Victoria, Virginia | Ubuntu 22.04 LTS | jammy |
Import CRAN APT Repository
Refresh Package Indexes and Update Installed Software
Before installing R on Linux Mint, update your system to ensure all existing packages are current. Open a terminal from the applications menu and run:
sudo apt update && sudo apt upgrade
Install Repository Tools
Next, install the helper packages that provide the add-apt-repository utility, GPG key management, and secure downloads. These tools enable repository access and key verification:
sudo apt install --no-install-recommends ca-certificates curl gpg software-properties-common
Download CRAN Repository Signing Key
Download and convert the signing key maintained by Michael Rutter, the CRAN Ubuntu repository maintainer. Since the published key is ASCII-armored, use curl to fetch it and pipe the output through gpg --dearmor to create the binary format APT requires:
curl -fsSL https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg
The fingerprint of this key is E298 A3A8 25C0 D65D FD57 CBB6 5171 6619 E084 DAB9, matching the CRAN documentation. To verify the downloaded key fingerprint matches, run the following command:
gpg --show-keys --with-fingerprint /usr/share/keyrings/cran.gpg
When you run this command, the output displays the key details you should verify against CRAN’s published fingerprint:
pub rsa2048 2010-10-19 [SCA] [expires: 2027-09-30]
E298 A3A8 25C0 D65D FD57 CBB6 5171 6619 E084 DAB9
uid Michael Rutter <marutter@gmail.com>
sub rsa2048 2010-10-19 [E] [expires: 2027-09-30]
Before proceeding, carefully compare the displayed fingerprint against the published key ID on the CRAN Ubuntu repository page to confirm authenticity.
Add the CRAN Repository
With the key in place, create a DEB822 .sources file for your Linux Mint release. Because Linux Mint returns Mint codenames (wilma, xia, vanessa, etc.) from lsb_release -cs rather than Ubuntu codenames, you must use the correct Ubuntu codename explicitly. The CRAN repository uses a flat structure, so the Suites: line includes the codename with a trailing slash and Components: remains empty. Choose the command matching your Mint version:
Linux Mint 22.x (Ubuntu 24.04 Noble):
echo "X-Repolib-Name: CRAN
Types: deb
URIs: https://cloud.r-project.org/bin/linux/ubuntu/
Suites: noble-cran40/
Components:
Signed-By: /usr/share/keyrings/cran.gpg" | sudo tee /etc/apt/sources.list.d/cran.sources
Linux Mint 21.x (Ubuntu 22.04 Jammy):
echo "X-Repolib-Name: CRAN
Types: deb
URIs: https://cloud.r-project.org/bin/linux/ubuntu/
Suites: jammy-cran40/
Components:
Signed-By: /usr/share/keyrings/cran.gpg" | sudo tee /etc/apt/sources.list.d/cran.sources
The -cran40 suffix indicates the ABI break introduced with R 4.0. Despite this suffix, CRAN publishes the newest stable R release for supported Ubuntu LTS versions.
Refresh Package Index
After adding the CRAN repository, refresh your package index so the system recognizes the new source:
sudo apt update
Look for a line similar to Get:X https://cloud.r-project.org/bin/linux/ubuntu/noble-cran40 (or jammy-cran40 for Mint 21) confirming the repository was added successfully. Verify the repository is active:
apt-cache policy r-base
The output should show a candidate version from the CRAN repository. Mint 22 users will see a .2404.0 suffix (Noble), while Mint 21 users will see .2204.0 (Jammy):
r-base:
Installed: (none)
Candidate: 4.5.2-1.2404.0
Version table:
4.5.2-1.2404.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/ Packages
Finalize R Installation
Core R Installation
Now that the CRAN repository is active, install the base R metapackage, which brings the interpreter, standard library, and documentation:
sudo apt install r-base
Install R Development Tools (Optional)
Additionally, power users who routinely compile CRAN packages from source should install r-base-dev to pull in headers, compilers, and documentation tools:
sudo apt install r-base-dev
Verify the R Installation
Once installation completes, confirm R is working by checking the version and build information:
R --version
If R installed correctly, the output displays the installed version along with platform and compiler details:
R version 4.5.2 (2025-10-31) -- "[Not] Part in a Rumble" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU General Public License versions 2 or 3. For more information about these matters see https://www.gnu.org/licenses/.
Optional Development Libraries for Package Compilation
Many CRAN packages require system development libraries to compile from source. Install these common dependencies to avoid compilation failures:
sudo apt install libssl-dev libxml2-dev libcurl4-openssl-dev
Specifically, these libraries support SSL connections (libssl-dev), XML parsing (libxml2-dev), and HTTP requests (libcurl4-openssl-dev), which are dependencies required by popular packages like httr, XML, and curl.
Alternatively, for a curated collection of recommended R packages, install the r-recommended metapackage:
sudo apt install r-recommended
Understand R Package Management
Console Installation vs System Package Management
R packages can be installed two ways: from the R console using install.packages(), or system-wide through APT using r-cran-* packages. Console installation downloads packages into your home directory (~/R/) and works for individual users without sudo privileges. In contrast, system packages install to /usr/lib/R/library/ and require sudo, making them available to all users on the system.
When to Use Each Method
Use console installation (install.packages()) for personal projects, testing packages, or when you need the latest CRAN release immediately. Alternatively, use APT packages (sudo apt install r-cran-*) for shared systems, reproducible deployments, or when you need dependency tracking for system libraries like database connectors or SSL support.
Install R Packages via CRAN
Launch the R Interpreter
With R installed on your Linux Mint system, you can now install R packages from the Comprehensive R Archive Network (CRAN). To start the R console, open your terminal and run:
R
This command launches the R interactive console. For most users, this user-level approach is preferred because packages install to your home directory without requiring elevated privileges.
Running R with
sudo -i Relevates privileges and can pose risks if installing untrusted packages. For personal projects, useRas a regular user instead so your package library stays in your home directory.
Install R Packages
Once inside the R environment, install packages using the install.packages() function. For example, to install the ggplot2 and tidyr visualization packages, type in the R console:
install.packages(c("ggplot2", "tidyr"))
After running this command, R will download the packages and their dependencies from CRAN, compile them if necessary, and install them to your library directory.
Update Installed R Packages
Keeping your R packages up-to-date is important for security and functionality. To update all installed packages without confirmation prompts, run in the R console:
update.packages(ask = FALSE)
As a result, this command efficiently updates all your installed packages to their latest versions from CRAN.
Remove R Packages
If you need to remove an installed R package, use the remove.packages() function. For example, to delete the dplyr package, type in the R console:
remove.packages("dplyr")
Consequently, this approach gives you complete control over your installed packages, keeping only those necessary for your current work.
Manage System-Wide R Packages with r2u (CRAN-Apt)
By default, the CRAN repository provides R packages as source code that compiles locally when you run install.packages(). However, for workflows requiring hundreds of packages (tidyverse, Bioconductor, or machine learning stacks), compilation takes hours and occasionally fails when system dependencies are missing. The r2u project solves this by prebuilding CRAN packages as Ubuntu binaries with automatic dependency resolution through APT.
For example, installing complex packages like tidyverse (90+ dependencies) from source requires compiling each dependency individually, which can take considerable time on modest hardware. In contrast, with r2u prebuilt binaries, the same installation completes in seconds because APT simply downloads and unpacks the packages. As a result, this difference becomes significant when setting up new development environments or onboarding team members.
The legacy c2d4u Launchpad PPA is no longer maintained. CRAN’s Ubuntu README now directs users to r2u for binary packages. If you previously used c2d4u, remove it to avoid stale packages and signature warnings (see cleanup instructions below).
Add the r2u Binary Repository
First, import the CRAN-Apt (r2u) signing key and verify its fingerprint:
curl -fsSL https://eddelbuettel.github.io/r2u/assets/dirk_eddelbuettel_key.asc | sudo gpg --dearmor -o /usr/share/keyrings/cranapt.gpg
Confirm the key matches the published fingerprint before trusting it:
gpg --show-keys --with-fingerprint /usr/share/keyrings/cranapt.gpg
The output should display the fingerprint AE89 DB0E E10E 60C0 1100 A8F2 A148 9FE2 AB99 A21A matching Dirk Eddelbuettel’s key as documented on the r2u GitHub page.
With the key verified, add the r2u .sources file. Because Linux Mint’s lsb_release returns Mint codenames rather than Ubuntu codenames, use the explicit Ubuntu codename for your Mint version:
Linux Mint 22.x (Ubuntu 24.04 Noble):
echo "X-Repolib-Name: CRAN-Apt Packages
Types: deb
URIs: https://r2u.stat.illinois.edu/ubuntu
Suites: noble
Components: main
Signed-By: /usr/share/keyrings/cranapt.gpg" | sudo tee /etc/apt/sources.list.d/cranapt.sources
After creating the sources file, refresh your package index:
sudo apt update
Linux Mint 21.x (Ubuntu 22.04 Jammy):
echo "X-Repolib-Name: CRAN-Apt Packages
Types: deb
URIs: https://r2u.stat.illinois.edu/ubuntu
Suites: jammy
Components: main
Signed-By: /usr/share/keyrings/cranapt.gpg" | sudo tee /etc/apt/sources.list.d/cranapt.sources
After creating the sources file, refresh your package index:
sudo apt update
r2u publishes amd64 binaries for Ubuntu 24.04 (noble) and 22.04 (jammy). Ubuntu 24.04 also receives arm64 builds. The repository syncs with CRAN daily, so package updates appear quickly after upstream releases.
Install Packages via APT
Once r2u is active, you can install complex stacks like tidyverse or rstan without compiling:
sudo apt install r-cran-tidyverse
Clean Up the Legacy c2d4u Launchpad PPA
If you previously added the c2d4u PPA, remove it to prevent stale packages and signature warnings:
sudo add-apt-repository --remove ppa:c2d4u.team/c2d4u4.0+
sudo rm -f /etc/apt/sources.list.d/c2d4u-team-ubuntu-c2d4u4_0_*.list /etc/apt/sources.list.d/c2d4u-team-ubuntu-c2d4u4_0_*.sources
sudo apt update
Troubleshooting Common R Installation Issues
GPG Signature Verification Failed
If apt update reports signatures could not be verified, first confirm the GPG key downloaded correctly to /usr/share/keyrings/cran.gpg and matches the expected fingerprint. Then re-download the key if the file is corrupt or missing:
curl -fsSL https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg
gpg --show-keys --with-fingerprint /usr/share/keyrings/cran.gpg
Package Compilation Fails During install.packages()
When compiling from source, R packages often require system development libraries. Install r-base-dev for compiler tools, plus specific libraries as error messages indicate. Alternatively, the r2u repository eliminates compilation entirely by providing prebuilt binaries:
sudo apt install r-base-dev libssl-dev libcurl4-openssl-dev libxml2-dev
Permission Denied When Installing Packages
If install.packages() fails with permission errors, you are likely running R with elevated privileges but trying to install to a user library, or vice versa. Instead, run R without sudo for personal package installation, or use sudo -i R only when installing system-wide packages intentionally.
Wrong Ubuntu Codename in Repository Configuration
Note that Linux Mint’s lsb_release -cs returns Mint codenames (wilma, xia, vanessa) rather than Ubuntu codenames. However, CRAN and r2u repositories require Ubuntu codenames (noble, jammy). If apt update fails with “repository does not have a Release file”, verify your .sources files use the correct Ubuntu codename for your Mint version as shown in the version mapping table above.
Remove R from Linux Mint
If you no longer need R on your system, remove R packages, clean up the CRAN repository files, and optionally delete user-installed packages and configuration.
Remove R Packages
First, remove the core R packages and their dependencies. The --purge flag removes configuration files along with the packages:
sudo apt remove --purge r-base r-base-dev r-recommended
sudo apt autoremove
Remove CRAN Repository Files
Next, remove the CRAN and r2u repository configurations and GPG keys to prevent future updates:
sudo rm -f /etc/apt/sources.list.d/cran.sources /etc/apt/sources.list.d/cranapt.sources
sudo rm -f /usr/share/keyrings/cran.gpg /usr/share/keyrings/cranapt.gpg
sudo apt update
Remove User-Installed R Packages (Optional)
The following command permanently deletes all R packages you installed in your home directory. If you have packages you want to keep, back them up first with
cp -r ~/R ~/R-backupbefore running the removal command.
R stores user-installed packages in your home directory. Remove this directory if you want a complete cleanup:
rm -rf ~/R
Finally, verify R has been removed by confirming the command is no longer found:
which R
If R was successfully removed from your system, this command should return no output.
Conclusion
You now have R installed on Linux Mint with access to the complete CRAN package ecosystem. With the CRAN repository enabled and the r2u mirror available for thousands of prebuilt binaries, you can install, update, and manage R packages system-wide or within your user environment. Use the R console for interactive package management in personal projects, or rely on r2u and APT for faster installations without compilation overhead.
Next Steps: R Development Environment
Now that R is installed, you can enhance your workflow with these complementary tools tailored for R development on Linux Mint:
Version control becomes critical when collaborating on R projects or publishing reproducible research. Install Git on Linux Mint to track changes, manage branches, and integrate with GitHub or GitLab for sharing analysis scripts and package development.
Similarly, compiler tools are required for building R packages from source that include C or Fortran code. If you installed r-base-dev, you already have the essentials, but for more complex compilation scenarios, install the full GCC toolchain on Linux Mint.
Additionally, RStudio Desktop provides syntax highlighting, project management, and interactive debugging for R development. Download the latest version from the Posit website. It works seamlessly with your CRAN installation and supports R Markdown for reproducible research documents.
Alternatively, Visual Studio Code offers a development environment through the R extension, which provides syntax highlighting, integrated terminal, and variable exploration. Install VS Code on Linux Mint, then add the R extension from the marketplace for a lightweight editor that supports multiple languages alongside R.
Useful Links
Below are valuable resources for learning more about R:
- R Project Official Website: Comprehensive information about R, its features, and the latest updates.
- CRAN Ubuntu Repository: Installation instructions and binaries for Ubuntu-based systems including Linux Mint.
- r2u Project: Prebuilt CRAN packages as Ubuntu binaries with APT dependency resolution.
- R Manuals: Official documentation covering R usage from basics to advanced programming.
- RStudio Desktop: Popular IDE for R development with syntax highlighting and project management.
Thank you very much! This page saved me a lot of problems
Thank you so much, this guide is amazing. The level of details and the simplicity of explanations are the best I have ever seen.
The installation guide is perfect. Thank you very much indeed. It works well. In adding a ppa repo, though,
” sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+” does not work on Linux Mint 22. It displays the message
“Cannot add PPA: ”This PPA does not support noble”.
I update my R from 4.1.2 to 4.4.1 using your advice. I have Linux Mint 21.3 Virginia . All it’s right. Right now I can work with GGally.
thanks a lot, it work perfectly.