Skip to content

Commit

Permalink
updated target-data/get_target_data.R with the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
kjsato committed Sep 20, 2024
1 parent 7a61b76 commit 948069a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions target-data/get_target_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ census_pop <- dplyr::mutate(
dplyr::filter(SEX == 0) %>%
dplyr::select(fips, age = AGE, contains("POPEST")) %>%
dplyr::mutate(POPEST2023_CIV = POPEST2022_CIV) %>%
dplyr::mutate(POPEST2024_CIV = POPEST2022_CIV) %>%
tidyr::pivot_longer(cols = contains("POPEST"), names_to = "year") %>%
dplyr::mutate(year = as.numeric(gsub("[[:alpha:]]|_", "", year)))

Expand All @@ -62,7 +63,7 @@ census_agegroup <- lapply(unique(age2st_age), function(age_grp) {

# RSV-Net
df <- arrow::read_parquet(
"auxiliary-data/rsv/rsv-net/weekly_rates_lab_confirmed_rsv_hosp.parquet")
tail(sort(dir("auxiliary-data/rsv/rsv-net/", full.names = TRUE)), 1))

# Standardize:
# - Load relevant age groups
Expand All @@ -74,7 +75,8 @@ df <- arrow::read_parquet(
# - Standardize column names (lower case, without space, dot)
rsv <- df %>%
dplyr::mutate(
date = as.Date(`Week ending date`, "%m/%d/%Y")) %>%
date = as.Date(`Week ending date`,
tryFormats = c("%m/%d/%Y", "%Y-%m-%d"))) %>%
dplyr::filter(
Sex == "All" & Race == "All" &
`Age Category` %in% c(
Expand Down Expand Up @@ -123,8 +125,12 @@ rsv_output <-
rsv_past_season <- read.csv("https://raw.githubusercontent.com/midas-network/rsv-scenario-modeling-hub/f183e8a1a8d2387f02c2e007527af48226370d03/target-data/rsvnet_hospitalization.csv")
rsv_past_season <- dplyr::filter(rsv_past_season, date < min(rsv_output$date))

# Archive past files
old_files <- dir("target-data/", full.names = TRUE, pattern = "rsvnet_hospitalization.csv")
file.rename(old_files, gsub("target-data/", "target-data/archive", old_files))

# Write output
rsv_output <- rbind(rsv_output, rsv_past_season)
write.csv(rsv_output, "target-data/rsvnet_hospitalization.csv",
write.csv(rsv_output, paste0("target-data/", Sys.Date(), "_rsvnet_hospitalization.csv"),
row.names = FALSE)

0 comments on commit 948069a

Please sign in to comment.