@@ -688,26 +688,26 @@ up_to_date_nssp_state_archive <- function(disease = c("covid", "influenza")) {
688
688
)
689
689
nssp_state %> %
690
690
select(geo_value , time_value , version = issue , nssp = value ) %> %
691
- bind_rows(get_nssp_github()) %> %
691
+ bind_rows(get_nssp_github(disease )) %> %
692
692
as_epi_archive(compactify = TRUE ) %> %
693
693
extract2(" DT" ) %> %
694
694
# End of week to midweek correction.
695
695
mutate(time_value = floor_date(time_value , " week" , week_start = 7 ) + 3 ) %> %
696
696
as_epi_archive(compactify = TRUE )
697
697
}
698
698
699
- get_nssp_github <- function (source = c(" github" , " socrata" )) {
699
+ get_nssp_github <- function (disease = c( " covid " , " influenza " ), source = c(" github" , " socrata" )) {
700
700
source <- arg_match(source )
701
701
if (source == " github" ) {
702
702
raw_file <- read_csv(" https://raw.githubusercontent.com/CDCgov/covid19-forecast-hub/refs/heads/main/auxiliary-data/nssp-raw-data/latest.csv" )
703
703
} 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} " ) )
705
705
}
706
706
state_map <- get_population_data() %> % filter(state_id != " usa" )
707
707
raw_file %> %
708
708
filter(county == " All" ) %> %
709
709
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} " )) ) %> %
711
711
mutate(time_value = floor_date(time_value , " week" , week_start = 7 ) + 3 ) %> %
712
712
mutate(version = Sys.Date())
713
713
}
0 commit comments