Week 10

More purrring
Published

March 12, 2026

Modified

March 17, 2026

Topics

Part 10:

  • Use map() functions from the purrr package to iterate functions
  • Nest datasets into list-columns, and iterate statistical modeling and/or visualization functions over those elements
  • Use map2() from the purrr package to iterate functions across two inputs
  • Learn how to iterate regression modeling across different model variables

Announcements

  • Please fill out the course evaluations for the class.
    • Course evaluations are very helpful for making improvements to our classes.
    • If too few students fill out the evaluations, they are not released to me.
  • Please complete the SPH’s Annual Student Survey
    • Responses help us improve our SPH programs!
  • Cascadia R Conf in June 26-27 this year. It will be held at OHSU in RLSB. This is a great conference to meet other R enthusiasts in the area and learn more about what they are working on.

Class materials

  • Class materials in OneDrive folder BSTA_526_W26_class_materials_public.
  • For today’s class, make sure to download to your computer the folder called part10.
  • Open RStudio by double-clicking on the project file called BSTA_526_W26_class_materials_public.Rproj in the main OneDrive folder.

Note: The link to the slides version of the class notes is not working. Please see the OneDrive folder for the html of the slides.

Part OneDrive folder Slides Webpage
10

Readings

Required

Optional

  • Great classic purrr resources. The drawback is that some of the functions have newer versions in the mean time. I am still recommending them though since they are classics and give great overviews of purrr and map().
  • Combining bromm’s tidy() with purrr:::map(): broom and dplyr

Suggested additional R readings

  • Useful vignettes on table output: gtsummary intro to tbl_summary
  • tidy evaluation: Programming with dplyr - in case I can’t get to tidy evaluation use for functions with tidyverse
  • ggplot2 in packages
    • Examples how to use ggplot inside functions. It’s meant for people writing packages, but’s helpful in general.
  • Ted Laderas’s interactive workbook on learning rowwise and nested data: learning rowwise
  • [Dates and times in R for Data Science](https://r4ds.hadley.nz/datetimes.html
  • Cross tables with gtsummary::tbl_cross()

For learning more about statistics with R:

Post-class survey

  • Please fill out the post-class survey to provide feedback. Thank you!
  • Previous muddiest points and clearest points with responses are collected here.

Homework

  • See OneDrive folder for homework assignment.
  • HW 10 due on 03/12.

Recording

  • In-class recording links are on Sakai. Navigate to Course Materials -> Schedule with links to in-class recordings.