Chapter 1. The Recipes

1.1. Downloading and Installing R

Problem

You want to install R on your computer.

Solution

Windows and OS X users can download R from CRAN, the Comprehensive R Archive Network. Linux and Unix users can install R packages using their package management tool.

Windows
  • Open http://www.r-project.org/ in your browser.

  • Click on “CRAN”. You’ll see a list of mirror sites, organized by country.

  • Select a site near you.

  • Click on “Windows” under “Download and Install R”.

  • Click on “base”.

  • Click on the link to download the latest version of R (an .exe file).

  • When the download completes, double-click the .exe file and answer the usual questions.

OS X
  • Open http://www.r-project.org/ in your browser.

  • Click on “CRAN”. You’ll see a list of mirror sites, organized by country.

  • Select a site near you.

  • Click on “MacOS X”.

  • Click on the .pkg file for the latest version of R, under “Files:”, to download it.

  • When the download completes, double-click the .pkg file and answer the usual questions.

Linux or Unix

The major Linux distributions have packages for installing R. Here are some examples:

DistributionPackage name
Ubuntu or Debianr-base
Red Hat or FedoraR.i386
SuseR-base

Use the system’s package manager to download and install the package. Normally, you will need the root password or sudo privileges; otherwise, ask a system administrator to perform the installation.

Discussion

Installing R on Windows or OS X is straightforward because there are prebuilt binaries for those platforms. You need only follow the preceding ...

Get 25 Recipes for Getting Started with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.