Programming for Applications

Chapter 1: Getting and Installing R

Yu-You Liou (NTU)

Shih Chien University

2026-08-03

Welcome to R

What Is R?

R (R Core Team 2024) is a free, open-source environment for statistical computing and graphics, descended from the S language developed at Bell Laboratories (Becker et al. 1988). Throughout this course, the single name “R” actually bundles several things together:

  • a programming language designed around data;
  • an interpreter that executes programs written in that language;
  • a graphics system for producing statistical figures;
  • a desktop application for Windows, macOS, or Linux that wraps the interpreter, the standard packages, and a user interface into one install.

Our textbook is R in a Nutshell (2nd ed.) (Adler 2012). This first chapter has one practical goal: get a working copy of R onto your machine.

Why R?

Note

Three reasons R dominates applied data work. It is free of license fees, it runs on every major platform, and it is surrounded by an enormous ecosystem of contributed packages covering nearly every statistical method ever published.

  • R is maintained by an international core team of developers and distributed through CRAN (the Comprehensive R Archive Network).
  • Because the source code is open, anyone can inspect how a method is implemented — and anyone can port R to a new platform. That openness is precisely why binaries exist for every major desktop system.
  • Everything you need for this course costs exactly zero dollars.

R Versions

The Release Cycle

  • The R Core Team publishes official releases on a regular schedule: historically twice a year (spring and autumn in the book’s era); today, one major x.y.0 release each spring, followed by patch releases (x.y.1, x.y.2, …) that fix bugs.
  • Version numbers follow the pattern major.minor.patch, e.g., 4.4.2.
  • A typical release brings bug fixes, performance improvements, and a few new functions. Genuine changes to the language are rare and usually touch only obscure corners (the book’s example: the type of NA in partially initialized arrays changed back in R 2.5).

Version Stability: Why You Should Not Worry

  • The textbook’s code was checked against R 2.15.1 (2012). Because the language is so stable, essentially every example still behaves the same way today; where modern R differs, these slides use the modern behavior.
  • The same logic applies to download links: filenames embed the version number (R-4.4.2-win.exe), so the exact name you see will always be newer than any screenshot or book. Just take the latest one.
  • Code you write against one recent version will almost always run unchanged on another. Results across nearby versions should be virtually identical.

Which Version Should You Use?

  • For this course: the latest released version from CRAN.
  • You can check what you are running at any time:
R.version.string
[1] "R version 4.6.0 (2026-04-24)"
  • Do not worry if your patch number differs from your neighbor’s — results will be identical for everything we do.

Getting and Installing R Binaries

Binaries, and Where to Find Them

A binary is a precompiled, ready-to-run build of R — the easiest installation route on every desktop platform. To get one:

  1. Visit the official site: https://cran.r-project.org and follow the Download link.
  2. The download link leads to a list of mirror sites, organized by country. CRAN is replicated worldwide; a geographically close mirror is usually also close on the network, hence fast. The modern “0-Cloud” mirror automatically routes you to a good server, so it is a safe default.
  3. Pick the installer matching your operating system and run it.

A few platform-specific notes follow — Windows and macOS users normally download and run installers themselves, while Linux users are better served by a package manager.

Windows

  • Click Download R for Windows → base → run the .exe installer.
  • Installation works like any other Windows program: easy if you have the right permissions, awkward if you do not (common on corporate or lab machines).
    • Simplest fix: install R as a standard user into your own file space (e.g., under your user directory).
    • Alternatively, install — and later install packages — as an Administrator account.
  • The default location is under %ProgramFiles%\R (usually C:\Program Files\R\), with a Start-menu entry in the group R.
  • Early in the book’s era CRAN’s Windows installer was 32-bit only (64-bit arrived with R 2.12, 2010); today both the installer and R itself are 64-bit on any modern machine, so no choices need to be made.

macOS

  • Click Download R for macOS and choose the build that matches your hardware:
    • Apple Silicon (M-series chips): the arm64 package.
    • Intel Macs: the x86_64 package.
  • The .pkg installer places an application called R in your Applications folder and a command-line R on your path: download, double-click, follow the prompts.
  • As with any application, you need adequate permissions on the machine — on your personal laptop that just means remembering your password; on a managed computer you may need the administrator’s help.
  • Older hardware or operating systems? CRAN keeps legacy builds of earlier R versions that may suit older systems better. (The book’s era offered separate universal binaries for OS X 10.4/10.5 — the same idea, two decades earlier.)
  • If you grab the wrong build for your chip, R will refuse to start — when in doubt, check About This Mac.

Linux and Unix: Package Managers

On Linux, the cleanest route is the distribution’s package-management system: it fetches R, resolves every other piece of software R needs, and makes later upgrades a one-line affair. Before you start, make sure you know the root password or have sudo privileges; otherwise you will need the system administrator.

# Debian / Ubuntu
sudo apt-get update
sudo apt-get install r-base r-base-dev

# Fedora / Red Hat (the book's era used: sudo yum install R.x86_64)
sudo dnf install R
  • Updating later is equally simple: sudo apt-get upgrade or sudo dnf update R brings you to the newest packaged version.
  • CRAN maintains its own repositories with newer builds than most distributions ship; instructions for adding them are on the CRAN Linux pages.
  • r-base-dev (or the equivalent) is worth installing too — it provides the compilers needed to build contributed packages from source.

Linux and Unix: Installing from Downloaded Files

If you prefer (or a package manager is unavailable), you can download the files and install manually:

  • CRAN provides precompiled packages for several distributions — Debian, Ubuntu, Fedora/Red Hat, SUSE — plus builds for Solaris.
  • On Red Hat–style systems the tool is RPM. The book’s example: having downloaded R-2.15.1.fc10.i386.rpm into ~/Downloads, install it with:
rpm -i ~/Downloads/R-2.15.1.fc10.i386.rpm
# Debian-style equivalent:
# sudo dpkg -i r-base-core_*.deb
  • Other Unix systems often have their own channels — for instance, R is available through the FreeBSD Ports collection. Consult your system’s documentation for installing third-party software.

Building R from Source

Should You Build Your Own R?

It is standard practice to build R from source on Linux/Unix — but not on Windows or macOS, where it is tricky and yields little benefit for ordinary users:

  • it will not save space — the build pulls in large supporting tools (LaTeX among them);
  • it will not save time — unless you already have every tool and a glacial network connection;
  • the one real payoff is squeezing out extra performance, which in practice is rarely the bottleneck, even on large data sets.

The fact that you can build R anywhere is, however, exactly how R reaches unusual platforms — a direct benefit of open source.

The Classic Build Sequence

For the curious, building on a Unix-like system follows the time-honored ritual:

tar -xzf R-4.4.2.tar.gz
cd R-4.4.2
./configure
make
sudo make install
  • configure inspects your system and prepares the build; make compiles; make install copies the result into place.
  • The textbook defers details to its later chapter on R internals; for the definitive treatment see the manual R Installation and Administration on CRAN.

Wrapping Up

Checking Your Installation

Launch R and confirm the console responds:

1 + 1
[1] 2
sessionInfo()$R.version$version.string
[1] "R version 4.6.0 (2026-04-24)"

If you see sensible output, your installation works and you are ready for Chapter 2, where we tour the user interface.

Tip

Keep R current. When a new version appears (CRAN announces them on the front page), upgrading follows exactly the same steps as installing — and on Linux, your package manager does it for you.