Installing R

Installing R

In the following tutorial, you will follow the installation process and in no time, you too will have a rich, complete environment for R programming on your own machine. Depending on your computer’s operating system, skip to the relevant section and following the corresponding guide.

Installing R for Windows 10 users

  1. Navigate to the website (clicking on the link opens it in a new tab) and click on Download R x.x.x for Windows (3.6.3 as of this writing, April 2020).
  2. Once downloaded, on your computer find the R-3.6.3-win.exe (again, as of this writing) executable file, double-click to run it and an installation wizard (“installer”) will take you through the rest of the installation process.
  3. For the most part, the default settings suggested by the Windows installer are sensible. Click ‘Next >’ to accept the settings, or set your preference (for example, where R should be installed to, or whether or not to create a Desktop icon).

Installing R for Mac OS (OSX) users

  1. Navigate to this website (clicking on the link opens it in a new tab) and under Latest release, click on the latest R-x.x.x.pkg binary.
  2. If you’re on OS X 10.8 or later, you will also want to install XQuartz. Navigate to XQuartz’s website and under the Quick Download heading, click on XQuartz-2.7.11.dmg (as of this writing, April 2020). Apple used to ship earlier OS X versions with it, but more recent versions require a manual installation. To check your OS Version, click on the apple icon at the top menu () and then under About This Mac you will see your OS Version (e.g. Version 10.15.2). This step ensures you can run services such as OpenGL and Tcl/Tk that depend on X11 (don’t worry if you don’t immediately understand the benefits – it will become clearer later.)
  3. Follow the on-screen instructions to complete the installation process for R and XQuartz. When in doubt, stay with the default settings.

Installing R for Ubuntu (or other Linux) users

  1. Launch the Terminal app either through CTRL+ALT+T (shortcut) or Ubuntu desktop
  2. In the terminal, issue the command sudo apt update to update the system package
  3. In the terminal, issue the command sudo apt -y install r-base to update the system package. The -y flag stands for “yes”, which tells the command to assume “yes” as an answer to all prompts.

Launching R

Verify that your R installation is successful by opening your Terminal or Command Prompt, and launch R by using the command r. Alternatively, locate the R application and launch it from there.

You should be greeted with the R startup message that looks like the following:

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale.

When you type getRversion() into your R shell, it will return “3.6.3” (or whatever version of R, depending on when you’re reading this tutorial).

A couple more notes before you go:

  1. Mind the capitalization. Like many other programming languages, R is case-sensitive so getRversion() , and not getrversion(), or getRVersion().
  2. This is an R command, so be mindful that you paste or type this into the R shell and not your command prompt, or Powershell or Command Prompt.
  3. If you are using the command line command r to launch an R shell, you can type quit() to exit and return to the default shell interface (bash or zsh, for example).
  4. As of macOS Catalina (10.15), Apple replaces bash with zsh as the default shell. When you launch Terminal and type r into it, it will no longer launch the R shell, but rather “repeat” your last-issued command. If you would like r to actually launch R, you will need to disable it in your zsh settings. Use nano (a lightweight editor) to edit this configuration file by entering nano ~/.zshrc. This opens up the content of your zsh configurations in nano. Add disable r as a new line onto the last line of the file and then hit ^X (CTRL+X) to exit the file. When prompted if you’d like to save your changes, hit Y to indicate “yes”.

    This step (step 4) is entirely optional and only affects Mac OS users on version Catalina and later. In the next section, we will install RStudio, a professional editor that we can write our R code in. For the most part of your learning journey, you will be writing R code directly into RStudio.

Scroll to Top