Skip to content

Modernize pipe operator and recode() usage - #149

Open
jt14den wants to merge 1 commit into
mainfrom
modernize/native-pipe-and-case-match
Open

Modernize pipe operator and recode() usage#149
jt14den wants to merge 1 commit into
mainfrom
modernize/native-pipe-and-case-match

Conversation

@jt14den

@jt14den jt14den commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Converts %>% 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+ per renv.lock).
  • Replaces dplyr::recode(), which is marked [Superseded] on the current dplyr reference page, with case_match() in episodes 3 and 5. Each conversion includes an explicit .default argument to preserve recode()'s pass-through behavior for any value not in the mapping list, since case_match() returns NA for unmatched values by default.
  • Updates the accompanying prose (objectives, section headings, exercise text, keypoints) to match.

Test plan

  • sandpaper::validate_lesson() passes with no errors
  • All four modified episodes knit cleanly from a fresh session with no rendered R errors
  • Verified case_match() output is byte-identical to recode() output when run against the actual episodes/data/books.csv for both subCollection and format
  • Confirmed every raw code value in the dataset is covered by the mapping list, so .default is a safety net rather than currently masking a data problem
  • Would appreciate a second read on the case_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

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.
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🆗 Pre-flight checks passed 😃

This pull request has been checked and contains no modified workflow files, spoofing, or invalid commits.

Results of any additional workflows will appear here when they are done.

@nickyjgarland

Copy link
Copy Markdown
Contributor

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()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants