Semester in Review

DAT 309, Fall 2026

Published

December 2, 2026

This page collects what we learned this semester, organized by topic rather than by week. Each section has a short summary of the main ideas, followed by links to the class pages where we covered them. Use it to review, and to find examples when you’re working on your final project.

Tools and workflow

R, Positron and Quarto

We wrote all of our work in Positron, using R scripts for quick experiments and Quarto documents (.qmd) for anything we wanted to share. A Quarto document mixes text, code and output, and renders to a single HTML page. We used the YAML header to set titles, tables of contents and themes, and chunk options like message: false to hide clutter.

Git and GitHub

Git keeps a history of your work, and GitHub shares it. We used the everyday cycle pull → edit → add → commit → push in a shared class repository, each working in our own folder so our changes didn’t collide. We also learned what to do when they do collide: rejected pushes, merges vs. rebases, and conflicts.

Working with data

Transforming data: rows and columns

The core dplyr verbs, chained with the pipe |>:

  • rows: filter() keeps rows that meet a condition, arrange() sorts them, distinct() removes duplicates, and slice_*() picks rows by position.
  • columns: select() picks columns, mutate() creates or changes them, and rename() renames them.

Summarizing and grouping

group_by() + summarize() turns many rows into one summary row per group: counts, means, medians and more. cut() turns a numeric variable into categories (like age groups), and case_when() creates categories from conditions.

Reshaping, importing and joining

Real data rarely arrives in the shape ggplot wants. pivot_longer() and pivot_wider() switch between wide (one column per variable or year) and long (one row per observation) data. We imported data from CSV and Excel files and straight from URLs with readr and readxl, cleaned names with janitor::clean_names(), and combined datasets with joins like left_join() and full_join().

Strings, numbers and regular expressions

The stringr functions (all starting with str_) detect, count, extract, replace and split text. Regular expressions make their patterns far more powerful: they can describe “any digit”, “a word at the start of a line”, and much more. We also cleaned up numbers: parsing them from text, counting, rounding and transforming.

Visualization

The grammar of graphics with ggplot2

Every ggplot is built from the same pieces: data, aesthetic mappings (aes(): which variable goes to x, y, color, …) and geoms (points, bars, lines, boxplots, …), added in layers with +. We matched the type of plot to the type of data: histograms and boxplots for one numeric variable, scatterplots for two, bars for categories, and facets to compare groups.

Styling plots

labs() sets titles and axis labels, scale_*() functions control colors and axes, and theme() controls everything else: fonts, grid lines, legends and backgrounds.

Animation, interactivity and special plots

gganimate turns a plot into an animation over time, and plotly makes plots interactive. We also built two kinds of plots from scratch: heatmaps (a grid of colored tiles with geom_tile()) and Voronoi diagrams (regions of space closest to each point, with ggforce).

Maps

A map is just polygons: map_data() gives the outline of every country or state as a table of points, which geom_polygon() draws. We joined our own data to those shapes with left_join() (using countrycode to match country names) to make choropleth maps: regions colored by a value. For U.S. states and counties we used usmap, and sf with geom_sf() for more detailed geographic data.

Statistics and modeling

Descriptive statistics

Measures of center (mean, median), spread (standard deviation, IQR) and counts, and the difference between describing the data we have and inferring something about a larger population.

Linear models

lm() fits a straight-line model that predicts one numeric variable from others. We read coefficients, p-values and R² from summary() and broom::tidy() / glance(), plotted coefficients with ggcoef_model(), and saw that a variable can be a strong predictor on its own but add nothing once a related variable is in the model.

Classification

Using the Voronoi cells of the penguin data, we predicted the species of a new penguin, split the data into training and testing sets, and measured the classifier’s accuracy.

Interactive apps with Shiny

A Shiny app has a UI (the inputs and outputs the user sees) and a server (the R code that responds). Reactivity is the key idea: when an input changes, every output that depends on it updates automatically. We used reactive() and eventReactive() to share work between outputs, reactiveVal() to remember clicks, and bslib layouts and value_box() to make apps look good.

Real-world data we explored

Much of the semester was spent on real, messy data from public sources, learning to read documentation, download extracts and clean them.

Reference pages

Short, reusable recipes for common tasks.

Projects