R Installation and Setup

Overview

This unit covers the installation and setup of R.

Goals

  • Download and install the appropriate R version for your platform.
  • Get R running on your machine.

Reading

Installation

R can be freely downloaded from its website. Pick the version that matches your operating system and architecture. It should be possible for you to install it without having admin rights. However, your mileage might vary and it is possible that you might need administrator rights after all to install it.

You might be asked some questions during the install process. It is safe to always go with the defaults, unless you know you need something different.

Setup

Once R is installed, you can open it. The graphical interface you see will look pretty outdated. That’s ok, we basically never use R through its own interface, instead we are going to only use it through an IDE like Positron.

Quick spin

Just to make sure R is running, you can type some math into the console at the > sign. E.g. if you type 2+2, you should get 4 as a result.

Most of the power of R comes from add-ons called packages, which we’ll cover shortly. For now, you can try to install one. Type install.packages('dplyr') into the console. You might be asked to select a CRAN mirror. Just pick the first one (Cloud) - or really any. This will download and install the dplyr package, which is a very useful package for data manipulation. To check if it worked, type library(dplyr). You’ll see some messages, maybe even a warning message about the package having been built under a different version of R. That’s ok for now, as long as you don’t get any error messages.

R should be working and ready to use. You can close it.

Updating R

R is pretty stable and not much changes between versions. As long as you have one of the more recent versions installed, you should be good. If you want to upgrade, just install the new version. It will not override the old one, so if you want to get rid of that one, you need to uninstall it yourself.

Note that when you update to a new version of R, you might also need to re-install R packages (discussed shortly.)

Rtools Install

If you just plan to use R and R packages as they are, you are all set and don’t need Rtools. However, if you plan on compiling packages from source on Windows, you will need to install Rtools.. Make sure to download the version that matches your R version. Follow the installation instructions on that page.

Summary

We discussed how to install R and how to keep it updated. You should now be ready to use it.

Further Resources

See the note in the further resources section of the introductory unit. There is lots of information available online, including install/setup. If you have any issues, just ask Google or your favorite AI for help.

Test yourself

What is the recommended source for downloading the R installer to ensure you get the correct version?

Use the official R website (which links to CRAN) to download the installer so you get an up-to-date, unmodified version.

  • True
  • False
  • False
  • False

How can you quickly confirm that R is running after installation?

Running a simple calculation like 2+2 at the R console prompt should return 4, confirming R is working.

  • False
  • False
  • True
  • False

What is the typical way to update R, and what might you need to redo afterward?

Updating R usually means installing the new version alongside the old one; after upgrading you often need to reinstall packages for the new version.

  • True
  • False
  • False
  • False

Practice

  • Open R, run 2+2, and confirm you see 4 in the console.
  • Run sessionInfo() or version in R to double-check your installation details.
  • Install a small package (e.g., install.packages("palmerpenguins")), load it with library(), and run one example from its help file.
  • Restart R and run a saved script via source("path/to/script.R") to ensure your setup works across sessions.