Open
Conversation
c056849 to
6514c7e
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces nested ifelse() statements with case_when() statements to improve code readability and performance. The changes eliminate deeply nested conditional logic that was difficult to follow and potentially inefficient due to ifelse() evaluating all arguments.
- Refactored nested
ifelse()blocks in two files to usecase_when()for cleaner conditional logic - Improved variable naming and code structure in the population projection calculations
- Enhanced readability while maintaining the same functional behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Master RMarkdown Document & Render Code/Global Script.R | Simplified number formatting function using case_when() instead of nested ifelse() |
| Demographics/1. Demographics - Population.R | Replaced multiple nested ifelse() blocks with case_when() and refactored population projection logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
fc1a28d to
2ccad16
Compare
9c52e9d to
8a1275a
Compare
8a1275a to
2127cf4
Compare
34d8563 to
a92efbf
Compare
f83b651 to
cd70731
Compare
3ff02cd to
affca5b
Compare
Also used glue to make it more readable. This change also ensures the text is referring to the latest years available, whereas it was previously hardcoded to the 6th year (`pop_proj_dat[6, 2]`) Style code Update Demographics/1. Demographics - Population.R Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Update Master RMarkdown Document & Render Code/Global Script.R Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
affca5b to
39551a8
Compare
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.
Suggested by
{lintr}I think the code is significantly more readable now, however, ensuring it's functionally the same is a bit tricky, especially for the more complicated block in Demographics!