Skip to content

Commit 675bb44

Browse files
committed
adding nssp to flu
1 parent 66462e0 commit 675bb44

File tree

2 files changed

+240
-65
lines changed

2 files changed

+240
-65
lines changed

R/aux_data_utils.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,26 +688,26 @@ up_to_date_nssp_state_archive <- function(disease = c("covid", "influenza")) {
688688
)
689689
nssp_state %>%
690690
select(geo_value, time_value, version = issue, nssp = value) %>%
691-
bind_rows(get_nssp_github()) %>%
691+
bind_rows(get_nssp_github(disease)) %>%
692692
as_epi_archive(compactify = TRUE) %>%
693693
extract2("DT") %>%
694694
# End of week to midweek correction.
695695
mutate(time_value = floor_date(time_value, "week", week_start = 7) + 3) %>%
696696
as_epi_archive(compactify = TRUE)
697697
}
698698

699-
get_nssp_github <- function(source=c("github", "socrata")) {
699+
get_nssp_github <- function(disease = c("covid", "influenza"), source=c("github", "socrata")) {
700700
source <- arg_match(source)
701701
if (source == "github") {
702702
raw_file <- read_csv("https://raw.githubusercontent.com/CDCgov/covid19-forecast-hub/refs/heads/main/auxiliary-data/nssp-raw-data/latest.csv")
703703
} else if (source == "socrata") {
704-
raw_file <- read_csv("https://data.cdc.gov/resource/rdmq-nq56.csv?$limit=1000000&$select=geography,week_end,county,percent_visits_covid")
704+
raw_file <- read_csv(glue::glue("https://data.cdc.gov/resource/rdmq-nq56.csv?$limit=1000000&$select=geography,week_end,county,percent_visits_{disease}"))
705705
}
706706
state_map <- get_population_data() %>% filter(state_id !="usa")
707707
raw_file %>%
708708
filter(county == "All") %>%
709709
left_join(state_map, by = join_by(geography == state_name)) %>%
710-
select(geo_value = state_id, time_value = week_end, nssp = percent_visits_covid) %>%
710+
select(geo_value = state_id, time_value = week_end, nssp = starts_with(glue::glue("percent_visits_{disease}"))) %>%
711711
mutate(time_value = floor_date(time_value, "week", week_start = 7) + 3) %>%
712712
mutate(version = Sys.Date())
713713
}

0 commit comments

Comments
 (0)