Installing R and Getting Started with RStudio on Windows/Linux/Mac OS

Filed Under: R Programming

Installing R on Windows

  • Go to on your internet browser.
  • Select download R link in the Getting Started section of the page which takes you to a list of CRAN (Comprehensive R Archive Network) mirrors list.
Cran Mirrors
Cran Mirrors
  • Select any mirror site of your installation. Here we have selected the 0-cloud site for installation.
  • Now select R for Windows in the list given in the mirror site.
Cran Windows Installation
Cran Windows Installation
  • From the given options, select base (which installs all the base packages), corresponding to install R for the first time.
  • Download the binary file.
  • The current version is R-3.6.2 for Windows and the size of the installation is about 83MB.
Windows R Installation
Windows R Installation
  • The file will now download as an executable.
  • Run the installation and go through the setup wizard.
  • The installation should be done in a few minutes.
  • Now, you will be able to run R by selecting it from the start menu.
R Console Windows
R Console Windows

Installing R on Linux/Ubuntu

  • Installing R can be done in a similar way as above for Ubuntu. But it can easily get confusing as there are several options available to select.
  • Instead, to do a basic installation on your Ubuntu machine, go to the terminal and run the command sudo apt install r-base to proceed with the base package installation.
  • You will be notified of all the packages about to be installed. Type in Y to continue with the installation.
  • You can start running the R environment from your terminal using sudo -i R command.
R Commandline Ubuntu
R Command-line Ubuntu

This is the most straightforward way to run R. However, beginners benefit a lot from using an IDE like RStudio for their initial foray into R programming. The following section helps you get started with RStudio as well.

Installing R on Mac OS

  • Go to the and click on the “download R” link. It will open the CRAN mirrors page.
  • Select any mirror from the list. I would suggest you select the nearest one from your location for faster download.
  • In the mirror page, click on the Download R for (Mac) OS X link.
  • Download the latest release package, which is R-3.6.2.pkg as of writing this guide.
  • Open the downloaded R package installer file. It will run the installer and you should see the below window.
R Mac Package Installer
R Mac Package Installer
  • Press the “Continue” button. The installation is straight-forward as there are no options to select. Once the installation is finished, you should see the below window for the successful installation message.
R Mac Installed Successfully
R Mac Installed Successfully

Validating R installation on Mac OS

We can validate the R installation through the command-line by running the following commands.

R --version
Rscript --version

It should show the version of R that we have just installed.

R Version Command Mac
R Version Command

Another way to verify the installation is to run the R app from the applications directory. It will open the “R Console” to run R applications.

R Console App
R Console App

Getting started with RStudio

RStudio is a commercially developed IDE (Integrated Development Environment) for R. Unlike the traditional R console we installed above, RStudio provides syntax highlighting for easy debugging, space for displaying your graphical plots and history of commands for easy debugging and workspace management.

RStudio comes in Desktop and Server versions. The desktop version is free and it is enough to get you started with R.

Once you select the Download option for RStudio Desktop from here, you will be automatically redirected to a page with download links all OS types. The installation is straightforward from there.

Once you install and run RStudio, you will get a window like this. This is your RStudio console.

Rstudio Environment
RStudio Environment

As you play around, you will see that the RStudio window has the following components. Each of them has different functionality.

  • The command console – This is where you type and execute your commands. Try giving a small arithmetic command in the console like 5 + 5 and then press Enter to see the result displayed on the command-line itself.
  • The script editor – Most of our R programs will be a collection of commands rather than a single command. Rather than clumsily entering the commands one by one in the command console, we prefer to store and load them as a script. This is where the script editor helps us. The script editor is usually invisible when you first run RStudio and can be activated by selecting File – > New File -> R Script from the top menu.
  • The scripts can be run using the Run button on top of the script editor panel. The results get displayed on the console.
  • The environment panel – This is located on the top-right of the RStudio window. This is where you can monitor all the active variables in the present environment.
  • The history panel – This panel, located right next to the environment panel, shows the history of all the commands run till now. It makes your job easy when you want to rerun commands.
  • The files panel – This can be seen at the bottom right region of the window. This shows all the files in the current directory. You can monitor the needed datasets from this panel.
  • The plots panel – This lies beside the files panel and displays your graphs when you execute the corresponding command.
  • The packages panel – As the name indicates, it gives a list of active packages in your environment.
  • The help panel – This panel displays searchable help topics about your selected packages and public datasets.

This is enough to get you started with RStudio for now. We will learn additional features as we move forward with the tutorial series.

Leave a Reply

Your email address will not be published. Required fields are marked *

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages