a quick exercise on clearer and safer iteration with R
Author
Ana Luisa Bodevan
Published
January 20, 2026
Iteration is a fundamental part of data analysis. Any time you repeat the same operation across columns, rows, or objects, you are iterating. Base R gives us for loops, and they are perfectly valid. However, as analyses grow in complexity, loops tend to become verbose, fragile, and harder to reason about.
The purrr package offers clearer, safer and more expressive ways to iterate in R, focusing on what you want to do with the loop rather than how to control it.