1  Computing Setup

This chapter will provide some details for setting up your computing environment to begin programming in R.

After reading this chapter you should be able to:

1.1 Operating System

We will support almost any operating system (OS), within reason, however we assume you will be using one of:

  • Windows
  • macOS
  • Linux

For each, we assume that your OS is reasonably up-to-date.1

1.2 Install R

R (R Core Team 2022) is a freely available language and environment for statistical computing and graphics. Use the appropriate link from the following2 to download and install R:

Use The Current Version of R

Many readers will already have R installed from previous R experience. Even if that is the case, we highly recommend re-installing R to insure you have the most recent version, which as of this writing if 4.2.33. You may need to re-install packages after doing so.

Intel Versus ARM For macOS

If you have an Intel-based Mac, select and install R-4.2.3.pkg. If you are using an ARM-based mac (M1 or M2), the Intel-based version will work through emulation using Rosetta2 in order for R to run properly. However, consider instead installing the ARM specific version of R by selecting and installing R-4.2.3-arm64.pkg.

1.3 Install RStudio

RStudio (RStudio Team 2020) is a free and open-source integrated development environment (IDE) for R. Use the link for “RStudio Desktop (Open Source License)” from the following4 to download and install RStudio:

Running Versus Installing RStudio On macOS

Be sure to actually install RStudio. Do not simply run RStudio from the disk image you downloaded. To install RStudio, drag RStudio from the disk image to your Applications folder. Once you have done so, eject the disk image, then open RStudio from the Applications folder.

RStudio Is Not R

RStudio is not R and R is not RStudio. You will need to have both installed. RStudio is an integrated development environment (IDE) that will assist you in writing R code and developing software.

1.4 Install Packages

The wonderful package system is a large part of what makes R a great language. To install several packages that we will need later, run the following code in R5:


To verify that this has worked, run the following:

#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr     1.1.0     ✔ readr     2.1.4
#> ✔ forcats   1.0.0     ✔ stringr   1.5.0
#> ✔ ggplot2   3.4.1     ✔ tibble    3.2.1
#> ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
#> ✔ purrr     1.0.1     
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag()    masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

If you do so, and your output looks relatively similar, you have successfully installed all of the packages of the tidyverse (Wickham et al. 2019).

We will further discuss installing and using packages later. For now, we’re mostly checking that your R and RStudio are setup correctly.

1.5 RStudio Setup

To see the wealth of ways that you can customize RStudio, take a look at Preferences. For example, many users prefer a dark theme. To change RStudio’s theme, see Appearance in the Preferences window.

In general, we advocate for keeping things as default as possible, however there are some noteworthy exceptions.6

1.5.1 Do Not Restore Old Workspaces

Due to some odd default settings in RStudio, some students never clear their R environment. This is a problem for a number of reasons.7 To avoid these issues, do the following:

  1. Clear your current environment.
  2. Change some RStudio defaults.
    • Deselect “Restore .RData into workspace at startup.”
    • Set “Save workspace .RData on exit:” to “Never”

Clear current enviroment.

Do not restore workspace on startup or save workspace on exit.

  1. We use “reasonably up-to-date” to mean that you are using the most recent “major” version of your operating system. At the very least, you should be apply all security patches for whatever “major” version of an OS you are using.↩︎

  2. Linux users: We assume you can figure out how to do this without us providing the links.↩︎

  3. Nickname: “Shortstop Beagle”↩︎

  4. Linux users: Again, you’re on your own.↩︎

  5. To do so, open RStudio and copy-paste the code into the “Console” panel, then press the [return] key, ⏎. More on this next chapter.↩︎

  6. If you are are student in STAT 385 and notice that the RStudio in the tutorial videos is setup differently than yours, and are interested in how to make the same modifications, please ask!↩︎

  7. It could prevent your results from being reproducible. It could cause R to run very, very slowly.↩︎