09. Iterating on Data and Models

Published

Tuesday, October 28, 2025

This week …

Repeatedly doing things to data; repeatedly doing things to models. Core functional programming patterns.

Reading

  • Hadley Wickham, Garrett Grolemund, and Mine Çetinkaya-Rundel R for Data Science: Import, Tidy, Transform, Visualize, and Model Data, 2nd ed. (Sebastopol, CA: O’Reilly Media, 2023), https://r4ds.hadley.nz.

Read the text online. Read Chapter 25 on functions and Chapter 26 on iteration.

Examples

This week’s examples and demos.

Assignment

Slides

The first batch of slides has what we covered in class, and a bit more besides. The second batch addresses two extensions: first, iterating safely, when you want to do things by group but some groups are missing and the iteration will fail if you don’t plan for it. Second, doing all fo this with survey-weighted data, which is a common special case.

View HTML slides in a new window Download a PDF of these slides

View HTML slides in a new window Download a PDF of these slides