📚 R Programming Tutorial

R Programming

Learn R programming concepts with simple explanations, examples, techniques and practical notes.

← Back to R Programming

Installing R

R programming is a very popular language and to work on that we have to install RGui.

Installing R to the local computer is very easy. First, we must know which operating system we are using so that we can download it accordingly.

The official site https://cloud.r-project.org provides installer files for major operating systems including Windows, Linux, and Mac OS.

Install R in Windows

To install R on your Windows, just follow these steps:

  • Download the R Installer File
  • Run the Installer
  • Install R
  • Add R to the PATH Environment Variable Manually
  • Verify the Installation

Step 1: Download the R Installer File

Go to the official R Project website (https://cloud.r-project.org) and download the latest version of R for Windows.

CRAN download page with Download R for Windows highlighted

To proceed, please click the link labelled Download R for Windows.

R for Windows page with install R for the first time highlighted

To proceed, please click the link labelled install R for the first time.

Download R-4.4.2 for Windows link on the CRAN website

To proceed, click the link labelled Download R-4.4.2 for Windows. Subsequently, the R Installer File will begin to download.

Step 2: Run the Installer

Open your downloads folder and double-click on the R installer file that you just downloaded.

You may be required to grant access based on your security configurations. Please permit it and continue.

Step 3: Install R

After executing the installer, you will encounter this screen.

R setup language dialog with English selected

Select your desired language. (Here English) and click on OK button.

R setup license information screen with Next button

And then click on Next button to accept licenses agreements.

You will be prompted to specify the installation directory. The default location is C:\Program Files\R\. You may retain this setting and continue with the installation by clicking on Next button.

R setup destination location screen showing C:\Program Files\R\R-4.4.2

The installer will then prompt you to choose components and where to place shortcuts. Click Next button to continue installation.

R setup Select Components screen with Main Files, 64-bit Files and Message translations selected

Select Start-up options, then click Next button.

R setup Startup options screen with No (accept defaults) selected

Select Start Menu Folder, then click Next button.

R setup Select Start Menu Folder screen with folder name R

Select Additional Tasks, then click Next button.

R setup Select Additional Tasks screen with desktop shortcut and file association options
R setup installing progress screen extracting files

Setup has finished installing R for Windows 4.4.2. Click Finish to exit the installer.

R setup completing wizard screen with Finish button

Step 4: Add R to the PATH Environment Variable Manually

It is essential to manually set that the PATH environment variable of your system is configured properly. To add the PATH environment variable, please follow these steps.

  • Copy the path where R is installed to the bin folder. (Usually, it is in C:\Program Files\R\R-4.4.2\bin)
  • Right-click on This PC and select Properties.
  • Click on Advanced System Settings and then Environment Variables.
  • Under User and System Variables sections, find and select Path, then click Edit.
  • Click New and paste the path.
Edit environment variable dialog with C:\Program Files\R\R-4.4.2\bin added to Path

Click OK to close all dialogs and apply the changes.

Step 5: Verify the Installation

After the installation is finished, you can confirm that R has been installed correctly by opening a command prompt (cmd) and entering the following command:

R --version

Command prompt showing R --version output for R version 4.4.2

Install R in Linux (Ubuntu)

Installing R on Linux is as simple as following three steps.

Step 1

In the initial step, it is essential to update all necessary files within our system by executing the command sudo apt-get update.

Step 2

In the second step, we will proceed to install the R programming language on our system by utilizing the command sudo apt-get install r-base.

Step 3

In the final step, we need to type R and hit enter to start using the R editor.