Intro to R Crash Course, Part 2
Friday, October 2 — continuation, incl. loops & apply functions
Friday, Oct 2, 12:10–1:00 PM, Asmundson 242. Continuation of Part 1 (Sep 25) — picks up where we left off, ending with loops vs. apply functions. Optional, but open to everyone.
Before you arrive
If you haven’t already, install R and RStudio — see the Setup guide.
The script we’ll work through in class
Same script as Part 1 — we continue from wherever we stopped on Sep 25. Follow along on your own laptop.
What’s in it:
- 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 — the focus for this session
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, now that the statistics fundamentals (Mon 9/28, Wed 9/30) are underway.
Back to the full Friday discussion schedule.