How to Install R on Linux, Windows and Mac

If you’re interested in data analysis, you may have heard of a popular tool called R, which is a popular choice among data analysts and statisticians, thanks to its advanced features and user-friendly interface.

However, the process of installing R can be tricky if you’re not familiar with it. That’s where this article comes in, we’ll guide you through the step-by-step process of installing R on your Linux, Windows, or Mac system.

This article comprises of:

Installing R on Linux Systems

To install R on Linux distributions, you must follow the below-given steps:

Install R on Ubuntu

$ sudo apt update -qq
$ sudo apt install --no-install-recommends software-properties-common dirmngr
$ wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
$ sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
$ sudo apt install --no-install-recommends r-base

Install R on Debian

$ sudo apt update
$ sudo apt install r-base r-base-dev

Install R on RHEL Systems

$ sudo dnf install R
OR
$ sudo dnf install epel-release
$ sudo dnf install R

Install R on OpenSUSE

# zypper install R-base R-base-devel

After completing the installation, you can run the version command to confirm R installation on Linux.

$ R --version

R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

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/.

Installing R on Windows

To install R on Windows, follow the below-given steps:

    1. Go to the R official website.
    2. Click on the download R option.
    3. Choose a CRAN Mirror according to your choice. You can select the 0-Cloud as your default CRAN mirror.
    4. Choose the Download R for Windows option if you are installing it on a Windows system.
    5. Select the install R for the first time if you are new to this tool.
    6. Click on the Download button to begin downloading R on Windows.

If you don’t like doing the above steps, you can simply visit the download R on Windows.

Run the .exe file downloaded on your Windows system and complete the onscreen instructions to successfully install R. After the installation, you can then run it from the desktop or Search menu in the Windows system.

Running R on Windows
Running R on Windows

Installing R on Mac

The steps for installing R on Mac are similar to those for Windows. However, here you must select Download R for macOS and then download the .pkg file on a Mac system.

After that, you can run the file and follow the onscreen instructions to successfully install R on Mac.

Note: You can also choose the same method for installing R on Linux. However, it’s better to go with installing R on a Linux terminal because it’s a straightforward one.

The installation of R will help the user perform several tasks related to the R programming language such as measuring the execution time of a function in R.

Conclusion

Installing R on Linux, Windows, and Mac is a straightforward process that can be completed by following a few simple steps.

For Linux, the installation can be done via the terminal, while for Windows and Mac, downloading the software from the official website is the preferred method. Regardless of the operating system, users can quickly install R and begin using its powerful data analysis and statistical tools.

If you read this far, tweet to the author to show them you care. Tweet a thanks
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at GeeksVeda is created by a team of experienced writers so that it meets our high-quality standards.

Join the GeeksVeda Weekly Newsletter (More Than 5,467 Programmers Have Subscribed)
Was this article helpful? Please add a comment to show your appreciation and support.

Got Something to Say? Join the Discussion...