You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.2 KiB

3 years ago
3 years ago
  1. # THIS IS NOT EXPORTED FROM MMWRweek but I need it
  2. # Find start date for a calendar year
  3. #
  4. # Finds the state date given a numeric calendar year
  5. # @author Jarad Niemi \email{niemi@@iastate.edu}
  6. .start_date = function(year) {
  7. # Finds start state for this calendar year
  8. jan1 = as.Date(paste(year, '-01-01', sep=''))
  9. wday = as.numeric(MMWRweekday(jan1))
  10. jan1 - (wday-1) + 7*(wday>4)
  11. }
  12. # CDC U.S. region names to ID map
  13. .region_map <- c(national=3, hhs=1, census=2, state=5)
  14. # CDC hospital surveillance surveillance area name to internal pkg use map
  15. .surv_map <- c(`FluSurv-NET`="flusurv", `EIP`="eip", `IHSP`="ihsp")
  16. .surv_rev_map <- c(flusurv="FluSurv-NET", eip="EIP", ihsp="IHSP")
  17. # CDC P&I mortality GepID mapping
  18. .geoid_map <- c(national="1", state="2", region="3")
  19. # Our bot's user-agent string
  20. .cdcfluview_ua <- "Mozilla/5.0 (compatible; R-cdcvluview Bot/2.0; https://github.com/hrbrmstr/cdcfluview)"
  21. # CDC Basemaps
  22. .national_outline <- "https://gis.cdc.gov/grasp/fluview/FluView2References/Data/US_84.json"
  23. .hhs_subregions_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView2References/Data/HHSRegions_w_SubGroups.json"
  24. .census_divisions_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView2References/Data/CensusDivs_w_SubGroups.json"
  25. .states_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView2References/Data/StatesFluView.json"
  26. .spread_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView8References/Data/States_Territories_labels.json"
  27. .surv_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView1References/data/US_States_w_PR_labels.json"
  28. # CDC Age Groups
  29. .age_grp <- c("0-4 yr", "5-24 yr", "25-64 yr", "65+ yr")
  30. # CDC Virus Groups
  31. .vir_grp <- c("A (Subtyping not Performed)", "A (H1N1)pdm09", "A (Unable to Subtype)",
  32. "B (Lineage Unspecified)", "A (H1)", "A (H3)", "B (Victoria Lineage)",
  33. "B (Yamagata Lineage)", "H3N2v")
  34. # Week Starts
  35. .tmp <- lapply(1962:2030, .start_date)
  36. mapply(function(.x, .y) {
  37. data_frame(
  38. wk_start = seq(.tmp[[.x]], .tmp[[.y]], "1 week"),
  39. wk_num = 1:length(wk_start)
  40. ) -> tmp
  41. tmp[-nrow(tmp),]
  42. }, 1:(length(.tmp)-1), 2:length(.tmp), SIMPLIFY=FALSE) -> .wk
  43. .wk <- Reduce(rbind.data.frame, .wk)
  44. .wk$mmwrid <- 1:nrow(.wk)