@@ -45,24 +45,14 @@ update_hub_target_data <- function(
4545 columns = nhsn_col_name ,
4646 start_date = nhsn_first_weekending_date
4747 ) | >
48- dplyr :: rename(
49- observation = nhsn_col_name ,
50- date = " weekendingdate"
51- ) | >
52- dplyr :: mutate(
53- date = lubridate :: as_date(.data $ date ),
54- observation = as.numeric(.data $ observation ),
55- jurisdiction = stringr :: str_replace(.data $ jurisdiction , " USA" , " US" )
56- ) | >
5748 dplyr :: mutate(
58- location = forecasttools :: us_location_recode(
59- .data $ jurisdiction ,
60- " abbr" ,
61- " code"
62- ),
49+ date = lubridate :: as_date(.data $ weekendingdate ),
50+ observation = as.numeric(.data [[nhsn_col_name ]]),
51+ jurisdiction = stringr :: str_replace(.data $ jurisdiction , " USA" , " US" ),
52+ location = forecasttools :: us_location_recode(.data $ jurisdiction , " abbr" , " code" ),
6353 as_of = !! today ,
6454 target = glue :: glue(" wk inc {disease} hosp" )
65- ) | >
55+ ) | >
6656 dplyr :: filter(! (.data $ location %in% !! excluded_locations ))
6757
6858 hubverse_format_nhsn_data <- nhsn_data | > dplyr :: select(- " jurisdiction" )
@@ -99,20 +89,20 @@ update_hub_target_data <- function(
9989 as_of = !! today ,
10090 target = glue :: glue(" wk inc {disease} prop ed visits" )
10191 ) | >
102- dplyr :: select(dplyr :: all_of(c(
92+ dplyr :: select(
10393 " date" ,
10494 " observation" ,
10595 " location" ,
10696 " as_of" ,
10797 " target"
108- ))) | >
98+ ) | >
10999 dplyr :: arrange(date , location )
110100
111101 output_file <- fs :: path(output_dirpath , " time-series" , ext = " parquet" )
112102 if (fs :: file_exists(output_file )) {
113103 existing_data <- forecasttools :: read_tabular_file(output_file )
114104 } else {
115- existing_data <- hubverse_format_nhsn_data [ 0 , ]
105+ existing_data <- NULL
116106 }
117107 dplyr :: bind_rows(
118108 existing_data ,
0 commit comments