Modernize pipe operator and recode() usage - #149
Conversation
Convert %>% to the native pipe |> throughout episodes 1, 3, 4, and 5, matching the current tidyverse style guide recommendation for R 4.1+ (this lesson already requires R 4.5+). Replace dplyr::recode() (superseded) with case_match() in episodes 3 and 5, including an explicit .default to preserve recode()'s pass-through behavior for values not in the mapping list. Verified case_match() output is identical to recode() output on the actual dataset (episodes/data/books.csv), and that .default isn't currently masking any data issue since every raw code value is covered by the mapping. Updated accompanying prose (objectives, headings, exercise text, keypoints) to match. Verified: sandpaper::validate_lesson() passes, and all four episodes knit cleanly from a fresh session with no rendered errors.
Thank you!Thank you for your pull request 😃 🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}. If you have files that automatically render output (e.g. R Markdown), then you should check for the following:
Rendered Changes🔍 Inspect the changes: https://github.com/LibraryCarpentry/lc-r/compare/md-outputs..md-outputs-PR-149 The following changes were observed in the rendered markdown documents: What does this mean?If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible. This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation. ⏱️ Updated at 2026-08-23 01:42:00 +0000 |
|
The changes in syntax all seem fine but while checking case_match() as a replacement I noted in the documentation that this function was also depreciated. Is there a benefit of using this function or should we switch to a suggested alternative such as recode_values()? |
Summary
%>%to the native pipe|>throughout episodes 1, 3, 4, and 5, matching the current tidyverse style guide recommendation for R 4.1+ (this lesson already requires R 4.5+ perrenv.lock).dplyr::recode(), which is marked[Superseded]on the current dplyr reference page, withcase_match()in episodes 3 and 5. Each conversion includes an explicit.defaultargument to preserverecode()'s pass-through behavior for any value not in the mapping list, sincecase_match()returnsNAfor unmatched values by default.Test plan
sandpaper::validate_lesson()passes with no errorscase_match()output is byte-identical torecode()output when run against the actualepisodes/data/books.csvfor bothsubCollectionandformat.defaultis a safety net rather than currently masking a data problemcase_match()conversions in episode 3 (lines ~203, ~221, ~551) and episode 5 (lines ~43, ~59, ~156) before merge, since this is a real behavioral change to double-check, not just a rename