Week 9
Iteration
Topics
Part 9:
- Introduce statistical modeling and learn how to fit a simple linear regression model and run a t-test in R
- Learn how to use
broomfunctions to tidy up statistical model output - Learn about
forloops - Understand how to apply a function to a list
- Learn how to iterate over a list using
map()functions from thepurrrpackage
Announcements
- Functions of the Week
- Please upload to Sakai your FOTW presentation by 7 am of the day you are presenting.
- 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
part9. - Open RStudio by double-clicking on the project file called
BSTA_526_W26_class_materials_public.Rprojin 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 |
|---|---|---|---|
| 9 |
Readings
Required
- R4DS book:
forloops: 27.5- Iteration: Chapter 26
- Section 26.2: Modifying multiple columns is on using the
across()function, such as inmutate(across()), which we’ve already covered. You can skip this section if you like. - Section 26.3 Reading multiple files introduces
purrr::map()which is new to us. Make sure to read this section.
- Section 26.2: Modifying multiple columns is on using the
- Learn to
purrrfrom Rebecca Barter’s blog. This is a nice non-technical introduction topurrrand the variousmapvariants.
Optional
purrrtutorial by Jenny Bryan- I recommend the Core
purrrlessons
- I recommend the Core
- Advanced R book (we’ve graduated from the R4DS book!) by Hadley Wickham
- Functionals: Chapter 9
- This chapter covers
purrrin detail. It’s the most technical of the suggested readings.
- This chapter covers
- Functionals: Chapter 9
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 9 due on 03/05.
Recording
- In-class recording links are on Sakai. Navigate to Course Materials -> Schedule with links to in-class recordings.