@@ -624,15 +624,16 @@ gen_ili_data <- function(default_day_of_week = 1) {
624
624
as_epi_archive(compactify = TRUE )
625
625
}
626
626
627
+ # ' Process Raw NHSN Data
628
+ # '
629
+ # ' Turns the raw NHSN data into a tidy format with the following columns:
630
+ # ' - geo_value: the jurisdiction of the data
631
+ # ' - disease: the disease of the data
632
+ # ' - time_value: the date of the data
633
+ # ' - version: the version of the data
634
+ # ' - value: the value of the data
635
+ # '
627
636
process_nhsn_data <- function (raw_nhsn_data ) {
628
- # These are exception dates when the data was available on a different day
629
- # than usual. In these two cases, it was the Thursday after. But to keep
630
- # the rest of the pipeline the same, we pretend it was available on Wednesday.
631
- remap_exceptions <- list (
632
- " 2024-12-26" = " 2024-12-25" ,
633
- " 2025-01-02" = " 2025-01-01"
634
- )
635
- fixed_version <- remap_exceptions [[as.character(Sys.Date())]] %|| % Sys.Date()
636
637
raw_nhsn_data %> %
637
638
mutate(
638
639
geo_value = tolower(jurisdiction ),
@@ -644,7 +645,7 @@ process_nhsn_data <- function(raw_nhsn_data) {
644
645
select(- weekendingdate , - jurisdiction , - starts_with(" totalconf" )) %> %
645
646
pivot_longer(cols = starts_with(" nhsn" ), names_to = " disease" ) %> %
646
647
filter(! is.na(value )) %> %
647
- mutate(version = fixed_version ) %> %
648
+ mutate(version = Sys.Date() ) %> %
648
649
relocate(geo_value , disease , time_value , version )
649
650
}
650
651
0 commit comments