Skip to content

Commit 1d66a7a

Browse files
committed
update with attempt at addressing review comments
1 parent 4607b5c commit 1d66a7a

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repos:
4848
args: ['--baseline', '.secrets.baseline']
4949
exclude: package.lock.json
5050
- repo: https://github.com/crate-ci/typos
51-
rev: v1
51+
rev: v1.39.1
5252
hooks:
5353
- id: typos
5454
args: ["--force-exclude"]

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Description: This package provides functions to help with the maintenance of CDC
99
License: Apache License (>= 2)
1010
Encoding: UTF-8
1111
Roxygen: list(markdown = TRUE)
12-
RoxygenNote: 7.3.2
12+
RoxygenNote: 7.3.3
1313
Imports:
1414
checkmate,
1515
cli,

R/get_webtext.R

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@
77
#' description of the current week's hospitalization
88
#' forecasts.
99
#'
10-
#' @param reference_date character, the reference date for
10+
#' @param reference_date Character, the reference date for
1111
#' the forecast in YYYY-MM-DD format (ISO-8601).
12-
#' @param disease character, disease name ("covid" or
12+
#' @param disease Character, disease name ("covid" or
1313
#' "rsv"). Used to derive hub name, file prefix, and
1414
#' disease display name.
15-
#' @param base_hub_path character, path to the forecast hub
16-
#' directory. Default: "."
17-
#' @param hub_reports_path character, path to forecast hub
18-
#' reports directory. Default: "../covidhub-reports"
19-
#' @param excluded_territories character vector of location
15+
#' @param base_hub_path Character, path to the forecast hub
16+
#' directory.
17+
#' @param hub_reports_path Character, path to forecast hub
18+
#' reports directory.
19+
#' @param excluded_locations Character vector of location
2020
#' codes to exclude from reporting calculations. Default:
2121
#' character(0).
2222
#'
2323
#' @export
2424
get_webtext <- function(
2525
reference_date,
2626
disease,
27-
base_hub_path = ".",
28-
hub_reports_path = "../covidhub-reports",
29-
excluded_territories = character(0)
27+
base_hub_path,
28+
hub_reports_path,
29+
excluded_locations = character(0)
3030
) {
3131
checkmate::assert_choice(disease, choices = c("covid", "rsv"))
32-
checkmate::assert_character(excluded_territories)
3332

3433
reference_date <- lubridate::as_date(reference_date)
3534

@@ -46,7 +45,8 @@ get_webtext <- function(
4645
reference_date
4746
)
4847

49-
# could possibly use write_ref_date_summary_ensemble() or summarize_ref_date_forecasts()
48+
# could possibly use write_ref_date_summary_ensemble() or
49+
# summarize_ref_date_forecasts()?
5050
ensemble_us_1wk_ahead <- forecasttools::read_tabular(
5151
fs::path(
5252
weekly_data_path,
@@ -97,15 +97,25 @@ get_webtext <- function(
9797

9898
desired_weekendingdate <- as.Date(reference_date) - lubridate::dweeks(1)
9999

100+
disease_abbr <- dplyr::case_match(
101+
disease,
102+
"covid" ~ "c19",
103+
"rsv" ~ "rsv"
104+
)
105+
106+
reporting_column <- glue::glue(
107+
"totalconf{disease_abbr}newadmperchosprepabove80pct"
108+
)
109+
100110
percent_hosp_reporting_below80 <- forecasttools::pull_data_cdc_gov_dataset(
101111
dataset = "mpgq-jmmr",
102-
columns = c("totalconfc19newadmperchosprepabove80pct"),
112+
columns = c(reporting_column),
103113
start_date = "2024-11-09"
104114
) |>
105115
dplyr::mutate(
106116
weekendingdate = as.Date(.data$weekendingdate),
107117
report_above_80_lgl = as.logical(
108-
as.numeric(.data$totalconfc19newadmperchosprepabove80pct)
118+
as.numeric(.data[[reporting_column]])
109119
),
110120
jurisdiction = dplyr::case_match(
111121
.data$jurisdiction,
@@ -123,7 +133,7 @@ get_webtext <- function(
123133
"name"
124134
)
125135
) |>
126-
dplyr::filter(!(.data$location %in% !!excluded_territories)) |>
136+
dplyr::filter(!(.data$location %in% !!excluded_locations)) |>
127137
dplyr::group_by(.data$jurisdiction) |>
128138
dplyr::mutate(max_weekendingdate = max(.data$weekendingdate)) |>
129139
dplyr::ungroup()

man/get_webtext.Rd

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)