Intro to R Crash Course, Part 1
Friday, September 25 — for anyone new to R
Friday, Sep 25, 12:10–1:00 PM, Asmundson 242. Basic R syntax, from scratch. Optional, but open to everyone — a good refresher even if you’ve used R before. Part 1 of 2 (continues Oct 2).
Quick self-check
Before we start, tell us where you’re at with R — this helps us pace the session. Tap the link below on your phone:
“How would you describe your R coding ability?” — Totally new to R · I’ve run others’ code · I’ve written my own code · I routinely use R to code and do analyses · I develop new tools in R
Before you arrive
If you haven’t already, install R and RStudio — see the Setup guide.
The script we’ll work through in class
This is the actual script — live, at the keyboard, not just slides. Follow along on your own laptop.
What’s in it (we’ll get as far as we get in 50 minutes — Part 2 on Oct 2 picks up where we leave off):
- Objects and 1D types in R (numeric, character, logical)
- Beyond numeric: factors, dates, and other types
- Vectors: creating, indexing, and vectorized operations
- Beyond 1D: lists and data frames
- Files, directories, and reading in data (
read.csv) - Basic plotting with
ggplot2 - The pipe operator
|> - Beginner+ skills: writing your own functions, and
forloops vs.apply-family functions (likely Oct 2 territory)
Data
The script reads in this dataset partway through — download it and keep it in your working directory:
Extra resources
Optional — if you’re new to R, or want more practice than we have time for in class.
Cheat sheets (quick reference, print or keep open in a tab):
- Posit cheat sheets — RStudio IDE, data visualization (
ggplot2), data transformation (dplyr/tidyr), and more, all one page each.
Guided tutorials / practice:
- swirl — learn R interactively, right inside the R console. No browser, no account. Good for drilling the basics at your own pace.
- Data Analysis and Visualization in R for Ecologists (Data Carpentry) — a full beginner-friendly workshop: R/RStudio basics,
ggplot2, data frames, and data wrangling, aimed at researchers with no programming background.
Free online book:
- R for Data Science (2e) — the standard reference for the tidyverse approach to importing, wrangling, and visualizing data in R. More than you need for this course, but a good thing to have on hand.
Video:
- StatQuest with Josh Starmer — short, clear explainer videos on R and statistics topics. A good channel to bookmark for later in the course too, once we get into the statistics fundamentals starting Mon 9/28.
Back to the full Friday discussion schedule.