Modernize pipe operator and recode() usage - #149
Open
jt14den wants to merge 1 commit into
Open
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.
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. |
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()? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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