Install R And RStudio On Windows, macOS, Linux, UNIX

In this guide, we will learn how to install R and RStudio on Windows, macOS, Linux, and UNIX [FreeBSD] and get our machine ready for some statistical research and data science.

The whole R and RStudio installation on all the above-mentioned operating system do not take more than 5-10 minutes of your time.

R is a free programming language and software environment for statistical computing and graphics created and maintained by the R Foundation for Statistical ComputingR is also a very popular programming choice among data scientists and statisticians for statistical computing, data mining, and design.

To use R to its maximum potential, you need to install two components on your machine: the R language and the RStudio Desktop IDE. This article covers both installations. In this tutorial, we will do just that.

Ready? Let’s get to work!

Install R and RStudio on Windows.

  1. Select a CRAN mirror

Open a browser and navigate to CRAN R-project website. CRAN is a set of worldwide distributed mirror servers to provide global coverage and fast download speeds for R setup and R packages. Select a mirror server that is nearest to your location. 

CRAN Mirrors. Source: uedufy.com
Install R and RStudio Windows – CRAN Mirrors

2. On the Download and install R section, click on Download R for Windows.

Download R for Windows. Source: uedufy.com
Install R and RStudio Windows – Download R

3. On the Download for Windows section, click on the base sub-directory.

Download R for Windows (base). Source: CRAN
Download R for Windows (base)

4. Click on the latest R release for Windows 32/64 bit. At the time of writing this guide, the latest version is R 4.0.4 but by the time you read this guide, a new R version might be available.

Download latest R Windows installer. Source: uedufy.com
Download latest R Windows installer

5. Once the download is completed, click on Open File to launch the installer. Alternatively, you can find and launch the R installer from your Download folder. 

Open R installer on Windows. Source: uedufy.com
Open R installer on Windows

6. Select Yes when prompted to allow this app to make changes to your computer.

Install R on Windows – User Account Control. Source: uedufy.com
Install R on Windows – User Account Control

7. On the Select Setup Language dialogue box, select your language and click OK.

Install R on Windows - Welcome. Source: uedufy.com
Install R on Windows – Welcome

8. On the Information window, review the GNU General Public License agreement and click Next.

R GNU General Public License. Source: uedufy.com
R GNU General Public License

On the Select Destination Location, click Next

Select Destination Location R Installer. Source: uedufy.com
Select Destination Location R Installer

9. Leave the default settings on the Select Components window to avoid 32/64 bit package compatibility issues later. Click Next.

Select R Components. Source: uedufy.com
Select R Components

10. On the Startup Options window, you can customize the installation further. For most cases, the default settings are sufficient. Leave the default No option selected and click Next.

R startup options. Source: uedufy.com
R startup options

11. On the Select Start Menu Folder window, leave the defaults and click Next

R Start Menu Folder. Source: uedufy.com
R Start Menu Folder

12. You can choose to create a Desktop or Quick Launch shortcut or proceed with the Select Additional Tasks window’s default settings. Click Install.

R Additional Tasks. Source: uedufy.com
R Additional Tasks

13. Windows will proceed to install R on your system. Once completed, click Finish to close the installation window. 

R Installation on Windows finished. Source: uedufy.com
R Installation on Windows finished

At this time, the R language is installed on our Windows machine. However, if you launch R now, you will be greeted by a console and a prompt. To make things much easier for us, we can install a front-end IDE for the R language called RStudio.

The RStudio IDE is a series of interconnected tools designed to enable you to code in R and Python more efficiently. It provides a console, syntax-highlighting editor that facilitates direct code execution, and a range of comprehensive resources for plotting, scanning, debugging, and handling the workspace.

14. To download RStudio Desktop IDE on your Windows computer, head over to the RStudio Desktop website, scroll down to the Download section and select the RStudio Desktop Free option. Click the Download button.  

Download RStudio for Windows. Source: uedufy.com
Download RStudio for Windows

15. In the All Installers section, download the Windows 10/8/7 .exe  installer.

Download RStudio for Windows Version. Source: uedufy.com
Download RStudio for Windows

16. Once the download is completed, click Open File to launch the RStudio Desktop Installer. The RStudio installer can be also found in your Download folder.

Open RStudio installer. Source: uedufy.com
Open RStudio installer

17. Select Yes when prompted to allow this app to make changes to your computer.

RStudio installer User Account Control. Source: uedufy.com
RStudio installer User Account Control

18. On the Welcome to RStudio Setup window, select Next.

RStudio installer Welcome. Source: uedufy.com
RStudio – Welcome

19. On the Choose Install Location window, select Next

RStudio – Chose Install Location. Source: uedufy.com
RStudio – Chose Install Location

20. On the Choose Start Menu Folder window, select Install

RStudio – Choose Start Menu Folder. Source: uedufy.com
RStudio – Choose Start Menu Folder

21. The RStudio Setup will proceed with the installation on your Windows machine. Once completed, click Finish.

RStudio – Installation Finished. Source: uedufy.com
RStudio – Installation Finished

22. To launch RStudio, click the Search icon on the Windows bar, search for RStudio and launch the RStudio IDE on your machine.

Launch RStudio in Windows. Source: uedufy.com
Launch RStudio in Windows

23. When prompted to Enable Automated Crash Reporting, click Yes.

Launch RStudio on Windows. Source: uedufy.com
Launch RStudio on Windows

Awesome! You just installed R and RStudio on Windows. Now go ahead and learn how to do some data analysis and statistics in R. Let’s learn next how to install packages in R using RStudio.

Install R and RStudio on macOS

  1. Open a browser and head over to CRAN R-project website. CRAN is a set of worldwide distributed mirror servers to provide global coverage and fast download speeds for R installers and R packages. Select a mirror server that is nearest to your country. 
CRAN mirrors download. Source: uedufy.com
CRAN Mirrors
  1. On the Download and Install R page, click on Download R for (Mac) OS X
Download R for macOS. Source: uedufy.com
Download R for macOS
  1. On the R for Mac OS X page, download the latest .pkg release.
Download R package for macOS. Source: uedufy.com
Download R package for macOS
  1. Launch the installer. You should find the R .pkg installer in your Download folder. On the R Welcome window, click Continue.
Launch R installer on macOS - Welcome. Source: uedufy.com
Launch R installer on macOS – Welcome
  1. Read the Important Information and click Continue.
R installer on macOS - Important information. Source: uedufy.com
R installer on macOS – Important information
  1. Read the Software Licence Agreement and click Continue
R Software License Agreement. Source: uedufy.com
R Software License Agreement
  1. When prompted to Agree with the Terms Of Software License Agreement, click Agree.
R Terms of Software License Agreement. Source: uedufy.com
R Terms of Software License Agreement
  1. Click the Install button to start the installation.
Install R on macOS – Standard Install. Source: uedufy.com
Install R on macOS – Standard Install
  1. When prompted, type your user password.
R Installation login. Source: uedufy.com
R Installation login
  1. Click the Close button. R is now installed on your macOS computer.
Install R on macOS – Installation finished. Source: uedufy.com
Install R on macOS – Installation finished.

The RStudio IDE is a collection of tools created to enable coding in R and Python more efficiently. Let’s install RStudio on our Mac next. 

  1. To download RStudio Desktop IDE on your macOS machine, navigate to the RStudio Desktop website, scroll down to the All Installers section, and download the macOS 10.13+ installer by clicking the .dmg file.
Download RStudio on macOS. Source: uedufy.com
Download RStudio on macOS
  1. Once the download is completed, launch the installer, usually located in your Download folder, and drag and drop the RStudio icon on your application folder.
Install RStudio on macOS. Source: uedufy.com
Install RStudio on macOS
  1. To launch the RStudio, head over to the Applications folder and double-click on the RStudio icon. When prompted if you want to open an application downloaded from the Internet, click Open.
Launch RStudio on macOS. Source: uedufy.com
Launch RStudio on macOS
  1. When prompted to Enable Automated Crash Reporting, click Yes.
Enable Crash Reporting on R. Source: uedufy.com
Enable Crash Reporting on R

That’s it. We just installed R and RStudio on macOS. You are now ready to write some cool code in R.

Launch R and RStudio on macOS. Source: uedufy.com
Launch R and RStudio on macOS

Install R and RStudio on Linux

In Linux, we have quite a number of distributions, but all of these distros are basically based on three main Linux branches: Debian (e.g., Ubuntu, Linux Mint, PopOS, etc.), RedHat (e.g., Fedora, CentOS, Suse Linux), and Arch (e.g., Manjaro, Endeavors OS).

Install R and RStudio on Debian-based distributions

R installation on Debian and Debian-based distributions is a straightforward process. In this guide, I will install R on Ubuntu 21.10. The installation method should be the same for newer Ubuntu versions.

  1.  To install R on Ubuntu, open a terminal and type:
sudo apt -y install r-base
  1. To install RStudio on Ubuntu, open a browser and head over to the RStudio Desktop website, scroll down to the All Installers section and select Ubuntu 18/Debian 10 .deb package.
Install RStudio on Linux – Download RStudio for Ubuntu. Source: uedufy.com
Install RStudio on Linux – Download RStudio for Ubuntu

  1. When prompted, select Save to download the file on your computer.
Install RStudio on Linux (Ubuntu). Source: uedufy.com
Install RStudio on Linux (Ubuntu)
  1. Navigate to your Download folder, right-click and select the Open in Terminal option. Alternatively, you can navigate to the Download folder using cd ~/download in the terminal.
Install RStudio on Ubuntu – Open the Terminal. Source: uedufy.com
Install RStudio on Ubuntu – Open the Terminal.
  1. To install the RStudio .deb package, type in the terminal the following command and use the Tab key on your keyboard to autocomplete the name of the file.
sudo dpkg -i rstudio<Hit Tab Key>
  1. If the installer complains about any missing dependencies, type in the terminal the following command: 
sudo apt --fix-broken install

Alternatively, you can use the following command to fix any broken dependencies:

sudo apt -f install
  1. To launch RStudio, find the application in your App Launcher or type in the terminal: RStudio When prompted to Enable Automated Crash Reporting, click Yes.

That all. You just installed R and RStudio on Ubuntu.

Run R and RStudio on Linux. Source: uedufy.com
Run R and RStudio on Linux

Install R and RStudio on RPM-based distributions

Follow this guide if you are using an RPM-based Linux distribution such as RHEL, Fedora, CentOS, etc. In this guide, I am going to use Fedora 36.

  1. To install R on Fedora, open a terminal and type:
sudo yum install R
  1. To install RStudio on Fedora, open a browser and head over to the RStudio Desktop website, scroll down to the All Installers section and select Fedora 28/Red Hat 8 .rpm package.
Download RStudio on Fedora. Source: uedufy.com
Download RStudio on Fedora
  1. When prompted, select Save to download the file on your computer. Navigate to your Download folder and double-click on the .rpm file you just downloaded. The Software Manager window will open. Click Install.
Install RStudio on Linux (Fedora). Source: uedufy.com
Install RStudio on Linux (Fedora)

5. Once the RStudio package is installed, click the Launch button.

Launch RStudio on Fedora. Source: uedufy.com
Launch RStudio on Fedora

When prompted to Enable Automated Crash Reporting, click Yes.

You are now ready to write code in R on your RPM-based operating system.

Launch R and RStudio on Fedora. Source: uedufy.com
Launch R and RStudio on Fedora.

Install R and RStudio on Arch-based distributions

Follow this guide if you are using Arch or any other Arch-based Linux distribution. In this guide, I am going to use Manjaro 21.

  1.  To Install R language on Arch-based systems, open a terminal and type:
sudo pacman -S r

Type Y when prompted to proceed with the installation.

  1.  Install RStudio IDE. To install RStudio, in the terminal type:
pamac build rstudio-desktop-bin
  1. Launch RStudio from the application launcher or by typing in the terminal: 
Rstudio-bin

When prompted to Enable Automated Crash Reporting, click Yes.

Launch R and RStudio on Manjaro (Arch). Source: uedufy.com
Launch R and RStudio on Manjaro (Arch)

And just like that, we managed to install R and RStudio on an Arch-based distribution. You gotta love Linux for its simplicity!

Install R and RStudio on UNIX [FreeBSD]

For UNIX, I chose the most popular UNIX distribution out there: FreeBSD. In this guide, I am using FreeBSD 13 with GNOME Desktop Environment but the same installation procedure applies to other Desktop Environments or Windows Managers out there.

1. Install R language by opening a terminal, switching to the root user (su -), and typing:

pkg install r

Bam! The R language is installed on FreeBSD!

2.  Install RStudio IDE on FreeBSD To install RStudio, in the terminal type as root:

pkg install RStudio

Alternatively, you can build the RStudio package from freshports by running the following command as root: 

cd /usr/ports/devel/RStudio/ && make install clean

[Optional] RStudio requires /proc to be mounted in /etc/fstab. To edit /etc/fstab, use the ee text editor or install nano using the following command as root:

pkg install nano

3. Next, edit the /etc/fstab:

nano /etc/fstab
  1. Add the following line into the /etc/fstab file:
proc /proc procfs rw 0 0

Your /etc/fstab file should look like this after adding the above line:

FreeBSD mount proc in fstab. Source: uedufy.com
FreeBSD mount proc in fstab

Save and quit the fstab file (press Ctrl+X then type Y to save).

  1. Mount /proc by running the following command:
mount /proc
  1. You can launch RStudio by launching the app or typing in the terminal: 
Rstudio

You are now ready to write code in R on FreeBSD operating system.

Launch R and RStudio on FreeBSD. Source: uedufy.com
Launch R and RStudio on FreeBSD

Wrapping Up

In this article, we learned how to install R and RStudio on Windows, macOS, Linux, and UNIX [FreeBSD] operating systems. 

As you see, installing R and RStudio on any OS is quite straightforward. Now go ahead and learn some statistics for R with me!

Default image
Leonard Cucos

Leonard is a Ph.D. student in Data Science and holds an MBA and B.Sc. He has an impressive public speaking profile on education, engineering, and research. He loves to help students achieve their academic objectives and believes education is the key to building a better future for mankind.

Articles: 25