06. More on dplyr and reshaping data

Published

Wednesday, October 1, 2025

This week …

More on dplyr: using across() to apply functions to multiple columns at once; using case_when() to create new variables based on conditions; more on reshaping data with pivot_longer(); more on filtering and selecting data.

Required Reading

  • Karl W. Broman and Kara H. Woo “Data Organization in Spreadsheets,” The American Statistician 72, no. 1 (January 2, 2018): 2–10, doi:10.1080/00031305.2017.1375989.

tidyr

stringr

  • Regular expressions
  • Read the help page for str_detect(): ?stringr::str_detect, which can also be found here. Work through the examples one at a time and make a note of any that seem confusing.

Examples

This week’s examples.

Assignment

Slides

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