-
Notifications
You must be signed in to change notification settings - Fork 3
Simplify dplyr
use in dashboard filter
logic
#266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of confirmations but otherwise good to go 🚀
scoreDf$ahead_group <- case_when( | ||
scoreDf$ahead >= HOSPITALIZATIONS_OFFSET & scoreDf$ahead < 7 + HOSPITALIZATIONS_OFFSET ~ 1L, | ||
scoreDf$ahead >= 7 + HOSPITALIZATIONS_OFFSET & scoreDf$ahead < 14 + HOSPITALIZATIONS_OFFSET ~ 2L, | ||
scoreDf$ahead >= 14 + HOSPITALIZATIONS_OFFSET & scoreDf$ahead < 21 + HOSPITALIZATIONS_OFFSET ~ 3L, | ||
scoreDf$ahead >= 21 + HOSPITALIZATIONS_OFFSET & scoreDf$ahead < 28 + HOSPITALIZATIONS_OFFSET ~ 4L, | ||
TRUE ~ NA_integer_ | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: this is a beautiful refactor
filteredScoreDf[, c("Forecaster", "Forecast_Date", "Week_End_Date", "Score", "ahead")], | ||
!is.na(Week_End_Date) | ||
) | ||
filteredScoreDf$Score <- round(filteredScoreDf$Score, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra explanation for future travelers:
This change is equivalent.
Score
is the only column where rounding to 2 decimal places will have any effect.
ahead
is numeric but takes integer values.
dplyr
-based processing steps simpler and fasterdata.table
's character vector-optimized "in" operator,%chin%
, in slow filter stepsdata.table
'swday
function to get weekday name from dates