How To Install R and RStudio [Windows, macOS, Linux, FreeBSD]

How To Install R and RStudio [Windows, macOS, Linux, FreeBSD]

This tutorial will teach you step-by-step how to install R on Windows, macOS, Linux, and FreeBSD, as well as the RStudio IDE on all operating systems mentioned above. Each operating system’s installation process does not require 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 a popular programming choice among data miners and statisticians for developing data analysis and statistical software.

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. 

Let’s get started.

Install R and RStudio on Windows.

Step 1: Download and Install R language

Open a browser and navigate to CRAN R-project websiteCRAN 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. 

Install R on Windows Mirrors
R Mirrors. Source: CRAN

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

Install R Windows Download Selection
Download R for Windows. Source: CRAN

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

Install R Windows Download Base
Download R for Windows. Source CRAN

The latest R release for Windows 32/64 bit is R-4.0.4 at the time of writing this guide. Click on Download R 4.0.4 for Windows

Install R Windows Installer File
Download R for Windows. Source: CRAN

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. 

Install R Windows Open File
Install R on Windows 10

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

Install R on Windows - User Account Control
Install R on Windows – User Account Control

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

Install RStudio on Windows Welcome
Install R on Windows – Welcome

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

Install R on Windows Public GNU license
Install R on Windows – GNU General Public License

On the Select Destination Location, click Next

Install R on Windows – Select Destination Location

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

Install R on Windows – Select Components

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

Install R on Windows installation options
Install R on Windows – Startup options

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

Install R on Windows installation start menu
Install R on Windows – Start Menu Folder

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

Install R on Windows installation additional tasks
Install R on Windows – Additional Tasks

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

Install R on Windows installation Finished
Install R on Windows – Installation Finished

Step 2: Download and Install RStudio IDE

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.

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

Install RStudio on Windows Download
Download RStudio

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

Install RStudio on Windows All Installers
Download RStudio for Windows

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.

Install RStudio Windows Open File
RStudio on Windows – Launch installer

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

Install RStudio Windows confirmation
User Account Control

On the Welcome to RStudio Setup window, select Next.

Install RStudio Windows Welcome
RStudio – Welcome

On the Choose Install Location window, select Next

Install RStudio Windows Install Location
RStudio – Chose Install Location

On the Choose Start Menu Folder window, select Install

Install RStudio Windows Choose Start Menu Folder
RStudio – Choose Start Menu Folder

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

Install RStudio Windows Installation Finished
RStudio – Installation Finished

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

Install RStudio Windows Launch RStudio
Launch RStudio in Windows 10

When prompted to Enable Automated Crash Reporting, click Yes.

You are now ready to write code in R on macOS.

Install RStudio windows, macOS
Install R and RStudio on Windows 10

Install R and RStudio on macOS

Step 1: Download and Install R language

Open a browser and head over to CRAN R-project websiteCRAN 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. 

On the Download and Install R page, click on Download R for (Mac) OS X

Install R macOS Download page
Download and Install R on macOS

On the R for Mac OS X page, download the latest .pkg release.

Install R macOS Download page pkg
Download and Install R on macOS – Latest Release

Launch the installer. You should find the R .pkg installer in your Download folder. 

On the R Welcome window, click Continue.

Install R macOS Installer Welcome
Install R on macOS

Read the Important Information and click Continue.

Install R macOS Installer License
Important Information

Read the Software Licence Agreement and click Continue

Install R macOS Installer Software License Agreement
Software License Agreement

When prompted to Agree with the Terms Of Software License Agreement, click Agree.

Install R macOS Installer Terms and Conditions
Terms of Software License Agreement

Click the Install button to start the installation.  

Install R macOS Install
Install R on macOS – Standard Install

When prompted, type your user password

Install R macOS install password
R Install Elevation

Click the Close button. R is now installed on your macOS computer. 

Install R macOS install finished
Install R on macOS – Installation finished.

Step 2: Download and Install RStudio IDE

The RStudio IDE is a collection of tools created to enable coding in R and Python more efficiently.

To download RStudio Desktop IDE on your macOS machine, navigate to the RStudio Desktop website, scroll down to the All Installers section, download the macOS 10.13+ installer by clicking the .dmg file.

Install RStudio macOS download
Download RStudio on macOS

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

To launch the RStudio, head over 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.

Install RStudio macOS download from Internet warning
Launch RStudio on macOS

When prompted to Enable Automated Crash Reporting, click Yes.

Install RStudio macOS crash report
RStudio on macOS – Enable Crash Reporting

You are now ready to write code in R on macOS.

Install RStudio windows, macOS
Install R and RStudio on macOS

Install R and RStudio on Linux 

For Debian-based distributions

R installation on Debian and Debian-based distributions (Ubuntu, Linux Mint, PopOS, etc.) is a straightforward process. In this guide, I will install R on Ubuntu 20.

Step 1: Install R language

To install R, open a terminal and type:

sudo apt -y install r-base

Step 2: Install RStudio IDE

To inst RStudio Desktop IDE on your machine, 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 Linux Deb download
Install RStudio on Linux (Ubuntu) – Download

When prompted, select Save to download the file on your computer. 

Install RStudio Linux download save
Install RStudio on Linux (Ubuntu)

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 Linux open in terminal
Install RStudio (Ubuntu) – Open terminal.

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<Tab>

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

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.

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

Install RStudio in Linux Ubuntu
Install R and RStudio on Linux (Ubuntu)

For 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 33.

Step 1: Install R language

To install R, open a terminal and type:

sudo yum install R

Step 2: Install RStudio IDE

To inst RStudio Desktop IDE on your machine, 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.

Install RStudio Fedora download
Install RStudio on Linux (Fedora)

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 Fedora Install app
Install RStudio on Linux (Fedora)

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

Install RStudio Fedora Launch app
Launch RStudio on Linux (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.

Install RStudio Fedora launch app
Install R and RStudio on Linux (Fedora)

For 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 20.1.

Step 1: Install R language

To install R, open a terminal and type:

sudo pacman -S r

Type when prompted to proceed with the installation.

Step 2: Install RStudio IDE

To install RStudio, in the terminal type:

pamac build rstudio-desktop-bin

You can launch RStudio by launching the app or typing in the terminal: 

rstudio-bin 

When prompted to Enable Automated Crash Reporting, click Yes.

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

Install RStudio Manjaro launch app
Install R and RStudio on Linux (Manjaro)

Install R and RStudio on FreeBSD

Follow this guide if you are using FreeBSD. In this guide, I am using FreeBSD 12.2 with GNOME Desktop Environment

Step 1: Install R language

To install R, open a terminal and type as root:

pkg install r 

Step 2: Install RStudio IDE

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

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

pkg install nano

Next, edit the /etc/fstab:

nano /etc/fstab

Add the following line into the /etc/fstab file:

proc /proc procfs rw 0 0

Your /etc/fstab file should look like this. 

Install R FreeBSD fstab mount proc
FreeBSD Mount proc in fstab

Save and quit fstab.

To mount /proc, run the following command:

mount /proc

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.

Install RStudio FreeBSD Gnome Version
Install R and RStudio on FreeBSD

Conclusion

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

If you found this guide useful, you can say thank you by sharing it with your friends and colleagues. However, if you encountered any issues or have any suggestions, drop me a message in the comment section below.

Stay safe!

Leonard

Call me Leo. I'm a technology addict and passionate engineer. If you can't find what you're looking for, drop me a message, and you'll have your step-by-step guide here in no time - I promise!

Leave a Reply