Hands-on Introduction to R 2023

Summary

Preparation

  1. Apply all the software updates available and restart the OS:
    • Windows 11 (≥22H2)
    • macOS Ventura (≥13.6)
  2. Configure OS to always show file extensions (suffixes of file names such as .pdf and .png)
  3. Download the latest R (≥4.3.2) from https://cran.r-project.org/. Install it with the default settings by pressing OK/Proceed. If you have old versions installed, remove them before new installation just in case.
    • Windows → baseR-4.*.*-win.exe
    • MacR-4.*.*-arm64.pkg (Apple Silicon) or R-4.*.*.pkg (Intel)
  4. Download the latest RStudio (≥2023.09.0) from https://posit.co/download/rstudio-desktop/ and install it. If you have old versions installed, remove them before new installation just in case.
  5. Install developer tools. They are not required here, but you will need them eventually.
    • Windows: Rtools (select the version corresponding to the R you installed)
    • Mac: Command Line Tools: Execute xcode-select --install on Terminal.app. Xcode itself is not necessary unless you want to develop iPhone apps.
  6. Launch RStudio, and execute the following line on the left panel called “Console”:
    install.packages("tidyverse", type = "binary")
    
    Answer yes if necessary. Many packages will be installed. If some errors or warnings come up, copy them to a text file to show me later.
  7. Execute the following two lines on Console, and check the message:
    library(conflicted)
    library(tidyverse)
    
    ── Attaching core tidyverse packages ───────────────── tidyverse 2.0.0 ──
    ✔ dplyr     1.1.4     ✔ readr     2.1.4
    ✔ forcats   1.0.0     ✔ stringr   1.5.1
    ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
    ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
    ✔ purrr     1.0.2
    

Slides

keys to go back and forth.