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
2424get_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()
0 commit comments