Skip to content

Commit

Permalink
separate variables in code for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Mar 19, 2024
1 parent bef71cb commit 0beec6f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ create_shifted_cases <- function(reported_cases, shift,
smoothing_window, horizon) {
shifted_reported_cases <- data.table::copy(reported_cases)[
,
confirm := data.table::shift(confirm,
shifted := data.table::shift(confirm,

Check warning on line 147 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=147,col=5,[object_usage_linter] no visible binding for global variable 'shifted'

Check warning on line 147 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=147,col=5,[object_usage_linter] no visible binding for global variable 'shifted'
n = shift,
type = "lead", fill = NA
)
][
,
confirm := runner::mean_run(
confirm, k = smoothing_window, lag = -floor(smoothing_window / 2)
smoothed := runner::mean_run(

Check warning on line 153 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=153,col=5,[object_usage_linter] no visible binding for global variable 'smoothed'
shifted, k = smoothing_window, lag = -floor(smoothing_window / 2)
)
]

## Forecast trend on reported cases using the last week of data
final_week <- data.table::data.table(
confirm = shifted_reported_cases[1:(.N - horizon - shift)][
confirm = shifted_reported_cases[1:(.N - horizon)][
max(1, .N - 6):.N]$confirm)[,
t := seq_len(.N)
][
Expand All @@ -180,7 +180,7 @@ create_shifted_cases <- function(reported_cases, shift,
confirm := data.table::fifelse(
t >= 7,
exp(lm_model$coefficients[1] + lm_model$coefficients[2] * t),
confirm
smoothed

Check warning on line 183 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=183,col=7,[object_usage_linter] no visible binding for global variable 'smoothed'
)
][, t := NULL]

Expand All @@ -189,7 +189,11 @@ create_shifted_cases <- function(reported_cases, shift,
confirm := ceiling(confirm)
]
shifted_reported_cases <- shifted_reported_cases[-(1:smoothing_window)]
return(shifted_reported_cases)
shifted_reported_cases <- shifted_reported_cases[,
shifted := NULL][,

Check warning on line 193 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=193,col=5,[object_usage_linter] no visible binding for global variable 'shifted'
smoothed := NULL

Check warning on line 194 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=194,col=5,[object_usage_linter] no visible binding for global variable 'smoothed'
]
return(shifted_reported_cases[])
}

#' Construct the Required Future Rt assumption
Expand Down

0 comments on commit 0beec6f

Please sign in to comment.