Browse Source

data cleanup/normalization; MMWRweeks integration; better README

tags/v0.7.0
boB Rudis 6 years ago
parent
commit
6f1faf27f2
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 3
      NAMESPACE
  2. 4
      R/aaa.R
  3. 4
      R/agd-ipt.r
  4. 2
      R/geographic-spread.R
  5. 13
      R/hospital.r
  6. 94
      R/mmwr-map.r
  7. 20
      R/pi-mortality.r
  8. 21
      R/who-nrvess.r
  9. 66
      README.Rmd
  10. 744
      README.md
  11. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-10-1.png
  12. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-12-1.png
  13. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-1.png
  14. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-2.png
  15. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-3.png
  16. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-4.png
  17. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-5.png
  18. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-6.png
  19. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-7-1.png
  20. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-1.png
  21. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-2.png
  22. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-3.png
  23. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-4.png
  24. BIN
      README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-9-1.png
  25. 21
      man/mmwr_week.Rd
  26. 24
      man/mmwr_week_to_date.Rd
  27. 29
      man/mmwr_weekday.Rd
  28. 15
      man/mmwrid_map.Rd
  29. 15
      tests/testthat/test-cdcfluview.R

3
NAMESPACE

@ -6,6 +6,9 @@ export(geographic_spread)
export(hospitalizations) export(hospitalizations)
export(ili_weekly_activity_indicators) export(ili_weekly_activity_indicators)
export(ilinet) export(ilinet)
export(mmwr_week)
export(mmwr_week_to_date)
export(mmwr_weekday)
export(mmwrid_map) export(mmwrid_map)
export(pi_mortality) export(pi_mortality)
export(state_data_providers) export(state_data_providers)

4
R/aaa.R

@ -1,3 +1,4 @@
# CDC U.S. region names to ID map # CDC U.S. region names to ID map
.region_map <- c(national=3, hhs=1, census=2, state=5) .region_map <- c(national=3, hhs=1, census=2, state=5)
@ -27,4 +28,5 @@
"B (Lineage Unspecified)", "A (H1)", "A (H3)", "B (Victoria Lineage)", "B (Lineage Unspecified)", "A (H1)", "A (H3)", "B (Victoria Lineage)",
"B (Yamagata Lineage)", "H3N2v") "B (Yamagata Lineage)", "H3N2v")
# Week Starts # Global HTTR timeout
.httr_timeout <- 120

4
R/agd-ipt.r

@ -21,7 +21,7 @@ age_group_distribution <- function() {
Referer = "https://gis.cdc.gov/grasp/fluview/flu_by_age_virus.html" Referer = "https://gis.cdc.gov/grasp/fluview/flu_by_age_virus.html"
), ),
# httr::verbose(), # httr::verbose(),
httr::timeout(60) httr::timeout(.httr_timeout)
) -> res ) -> res
httr::stop_for_status(res) httr::stop_for_status(res)
@ -56,6 +56,8 @@ age_group_distribution <- function() {
vir_df$age_label <- factor(vir_df$age_label, levels=.age_grp) vir_df$age_label <- factor(vir_df$age_label, levels=.age_grp)
vir_df$vir_label <- factor(vir_df$vir_label, levels=.vir_grp) vir_df$vir_label <- factor(vir_df$vir_label, levels=.vir_grp)
vir_df <- dplyr::left_join(vir_df, mmwrid_map, "mmwrid")
vir_df vir_df
} }

2
R/geographic-spread.R

@ -22,7 +22,7 @@ geographic_spread <- function() {
SeasonIDs = paste0(meta$seasons$seasonid, collapse=",") SeasonIDs = paste0(meta$seasons$seasonid, collapse=",")
), ),
# httr::verbose(), # httr::verbose(),
httr::timeout(60) httr::timeout(.httr_timeout)
) -> res ) -> res
httr::stop_for_status(res) httr::stop_for_status(res)

13
R/hospital.r

@ -49,7 +49,7 @@ hospitalizations <- function(surveillance_area=c("flusurv", "eip", "ihsp"),
cacthmentid = tgt$id cacthmentid = tgt$id
), ),
# httr::verbose(), # httr::verbose(),
httr::timeout(60) httr::timeout(.httr_timeout)
) -> res ) -> res
httr::stop_for_status(res) httr::stop_for_status(res)
@ -85,7 +85,16 @@ hospitalizations <- function(surveillance_area=c("flusurv", "eip", "ihsp"),
dplyr::mutate( dplyr::mutate(
surveillance_area = sarea, surveillance_area = sarea,
region = reg region = reg
) ) %>%
dplyr::left_join(mmwrid_map, "mmwrid") -> xdf
xdf$age_label <- factor(xdf$age_label,
levels=c("0-4 yr", "5-17 yr", "18-49 yr", "50-64 yr",
"65+ yr", "Overall"))
xdf[,c("surveillance_area", "region", "year", "season", "wk_start", "wk_end",
"year_wk_num", "rate", "weeklyrate", "age", "age_label", "sea_label",
"sea_description", "mmwrid")]
} }

94
R/mmwr-map.r

@ -26,6 +26,100 @@ mmwrid_map <- Reduce(rbind.data.frame, mmwrid_map)
mmwrid_map$mmwrid <- 1:nrow(mmwrid_map) mmwrid_map$mmwrid <- 1:nrow(mmwrid_map)
#' @title MMWR ID to Calendar Mappings #' @title MMWR ID to Calendar Mappings
#' @md
#' @description The CDC uses a unique "Morbidity and Mortality Weekly Report" identifier
#' for each week that starts at 1 (Ref: < https://www.cdc.gov/mmwr/preview/mmwrhtml/su6004a9.htm>).
#' This data frame consists of 4 columns:
#' - `wk_start`: Start date (Sunday) for the week (`Date`)
#' - `wk_end`: End date (Saturday) for the week (`Date`)
#' - `year_wk_num`: The week of the calendar year
#' - `mmwrid`: The unique MMWR identifier
#' These can be "left-joined" to data provided from the CDC to perform MMWR identifier
#' to date mappings.
#' @docType data
#' @name mmwrid_map #' @name mmwrid_map
#' @format A data frame with 4,592 rows and 4 columns
#' @export #' @export
NULL NULL
#' Convert a Date to an MMWR day+week+year
#'
#' This is a reformat and re-export of a function in the `MMWRweek` package.
#' It provides a snake case version of its counterpart, produces a `tibble`
#'
#' @md
#' @param x a vector of `Date` objects or a character vector in `YYYY-mm-dd` format.
#' @return data frame (tibble)
#' @export
#' @examples
#' mmwr_week(Sys.Date())
mmwr_week <- function(x) {
x <- as.Date(x)
x <- setNames(MMWRweek::MMWRweek(x), c("mmwr_year", "mmwr_week", "mmwr_day"))
class(x) <- c("tbl_df", "tbl", "data.frame")
x
}
#' Convert a Date to an MMWR weekday
#'
#' This is a reformat and re-export of a function in the `MMWRweek` package.
#' It provides a snake case version of its counterpart, produces a `factor` of
#' weekday names (Sunday-Saturday).
#'
#' @md
#' @note Weekday names are explicitly mapped to "Sunday-Saturday" or "Sun-Sat" and
#' do not change with your locale.
#' @param x a vector of `Date` objects or a character vector in `YYYY-mm-dd` format.
#' @param abbr (logical) if `TRUE`, return abbreviated weekday names, otherwise full
#' weekday names (see Note).
#' @return ordered factor
#' @export
#' @examples
#' mmwr_weekday(Sys.Date())
mmwr_weekday <- function(x, abbr = FALSE) {
x <- as.Date(x)
x <- MMWRweek::MMWRweekday(x)
if (abbr) {
x <- ordered(
x,
levels=c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"),
labels = c("Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat")
)
}
x
}
#' Convert an MMWR year+week or year+week+day to a Date object
#'
#' This is a reformat and re-export of a function in the `MMWRweek` package.
#' It provides a snake case version of its counterpart and produces a vector
#' of `Date` objects that corresponds to the input MMWR year+week or year+week+day
#' vectors. This also adds some parameter checking and cleanup to avoid exceptions.
#'
#' @md
#' @param year,week,day Year, week and month vectors. All must be the same length
#' unless `day` is `NULL`.
#' @return vector of `Date` objects
#' @export
#' @examples
#' mmwr_week_to_date(2016,10,3)
mmwr_week_to_date <- function(year, week, day=NULL) {
year <- as.numeric(year)
week <- as.numeric(week)
day <- if (!is.null(day)) as.numeric(day) else rep(1, length(week))
week <- ifelse(0 < week & week < 54, week, NA)
as.Date(ifelse(is.na(week), NA, MMWRweek::MMWRweek2Date(year, week, day)),
origin="1970-01-01")
}

20
R/pi-mortality.r

@ -59,12 +59,6 @@ pi_mortality <- function(coverage_area=c("national", "state", "region")) {
age_df <- setNames(meta$nchs_ages, c("ageid", "age_label")) age_df <- setNames(meta$nchs_ages, c("ageid", "age_label"))
age_df$ageid <- as.character(age_df$ageid) age_df$ageid <- as.character(age_df$ageid)
mwmr_df <- meta$mmwr
mwmr_df$mmwrid <- as.character(mwmr_df$mmwrid)
mwmr_df <- setNames(mwmr_df,
c("mmwrid", "weekend", "mwmr_weeknumber", "weekstart",
"year", "yearweek", "mwmr_seasonid", "mwmr_label", "weekendlabel"))
sum_df <- meta$nchs_summary sum_df <- meta$nchs_summary
sum_df$seasonid <- as.character(sum_df$seasonid) sum_df$seasonid <- as.character(sum_df$seasonid)
sum_df$ageid <- as.character(sum_df$ageid) sum_df$ageid <- as.character(sum_df$ageid)
@ -86,7 +80,7 @@ pi_mortality <- function(coverage_area=c("national", "state", "region")) {
AgegroupsParameters = list(list(ID="1")) AgegroupsParameters = list(list(ID="1"))
), ),
# httr::verbose(), # httr::verbose(),
httr::timeout(60) httr::timeout(.httr_timeout)
) -> res ) -> res
httr::stop_for_status(res) httr::stop_for_status(res)
@ -97,7 +91,7 @@ pi_mortality <- function(coverage_area=c("national", "state", "region")) {
dplyr::left_join(mapcode_df, "map_code") %>% dplyr::left_join(mapcode_df, "map_code") %>%
dplyr::left_join(geo_df, "geoid") %>% dplyr::left_join(geo_df, "geoid") %>%
dplyr::left_join(age_df, "ageid") %>% dplyr::left_join(age_df, "ageid") %>%
dplyr::left_join(mwmr_df, "mmwrid") -> xdf dplyr::left_join(dplyr::mutate(mmwrid_map, mmwrid=as.character(mmwrid)), "mmwrid") -> xdf
xdf <- dplyr::mutate(xdf, coverage_area = coverage_area) xdf <- dplyr::mutate(xdf, coverage_area = coverage_area)
@ -106,25 +100,23 @@ pi_mortality <- function(coverage_area=c("national", "state", "region")) {
} else if (coverage_area == "region") { } else if (coverage_area == "region") {
xdf$region_name <- sprintf("Region %s", xdf$subgeoid) xdf$region_name <- sprintf("Region %s", xdf$subgeoid)
} else { } else {
xdf$region_name <- NA_character_ xdf$region_name <- "national"
} }
xdf[,c("seasonid", "baseline", "threshold", "percent_pni", xdf[,c("seasonid", "baseline", "threshold", "percent_pni",
"percent_complete", "number_influenza", "number_pneumonia", "percent_complete", "number_influenza", "number_pneumonia",
"all_deaths", "Total_PnI", "weeknumber", "geo_description", "all_deaths", "Total_PnI", "weeknumber", "geo_description",
"age_label", "weekend", "weekstart", "year", "yearweek", "age_label", "wk_start", "wk_end", "year_wk_num", "mmwrid",
"coverage_area", "region_name", "callout")] -> xdf "coverage_area", "region_name", "callout")] -> xdf
suppressWarnings(xdf$baseline <- to_num(xdf$baseline)) suppressWarnings(xdf$baseline <- to_num(xdf$baseline) / 100)
suppressWarnings(xdf$threshold <- to_num(xdf$threshold)) suppressWarnings(xdf$threshold <- to_num(xdf$threshold) / 100)
suppressWarnings(xdf$percent_pni <- to_num(xdf$percent_pni) / 100) suppressWarnings(xdf$percent_pni <- to_num(xdf$percent_pni) / 100)
suppressWarnings(xdf$percent_complete <- to_num(xdf$percent_complete) / 100) suppressWarnings(xdf$percent_complete <- to_num(xdf$percent_complete) / 100)
suppressWarnings(xdf$number_influenza <- to_num(xdf$number_influenza)) suppressWarnings(xdf$number_influenza <- to_num(xdf$number_influenza))
suppressWarnings(xdf$number_pneumonia <- to_num(xdf$number_pneumonia)) suppressWarnings(xdf$number_pneumonia <- to_num(xdf$number_pneumonia))
suppressWarnings(xdf$all_deaths <- to_num(xdf$all_deaths)) suppressWarnings(xdf$all_deaths <- to_num(xdf$all_deaths))
suppressWarnings(xdf$Total_PnI <- to_num(xdf$Total_PnI)) suppressWarnings(xdf$Total_PnI <- to_num(xdf$Total_PnI))
suppressWarnings(xdf$weekend <- as.Date(xdf$weekend))
suppressWarnings(xdf$weekstart <- as.Date(xdf$weekstart))
xdf <- .mcga(xdf) xdf <- .mcga(xdf)

21
R/who-nrvess.r

@ -13,7 +13,8 @@
#' counterparts.\cr\cr #' counterparts.\cr\cr
#' Also, beginning for the 2015-16 season, reports from public health and clinical #' Also, beginning for the 2015-16 season, reports from public health and clinical
#' laboratories are presented separately in the weekly influenza update. This is #' laboratories are presented separately in the weekly influenza update. This is
#' the reason why a list of data frames is returned. #' the reason why a list of data frames is returned.\cr\cr
#' **ALSO** The new CDC API seems to be missing some public health lab data fields.
#' @param region one of "`national`", "`hhs`", "`census`", or "`state`" #' @param region one of "`national`", "`hhs`", "`census`", or "`state`"
#' @return list of data frames identified by #' @return list of data frames identified by
#' - `combined_prior_to_2015_16` #' - `combined_prior_to_2015_16`
@ -67,7 +68,7 @@ who_nrevss <- function(region=c("national", "hhs", "census", "state")) {
encode = "json", encode = "json",
body = params, body = params,
# httr::verbose(), # httr::verbose(),
httr::timeout(60), httr::timeout(.httr_timeout),
httr::write_disk(tf) httr::write_disk(tf)
) -> res ) -> res
@ -82,11 +83,25 @@ who_nrevss <- function(region=c("national", "hhs", "census", "state")) {
class(tdf) <- c("tbl_df", "tbl", "data.frame") class(tdf) <- c("tbl_df", "tbl", "data.frame")
tdf[tdf=="X"] <- NA tdf[tdf=="X"] <- NA
tdf[tdf=="XX"] <- NA
tdf tdf
}) -> xdf }) -> xdf
setNames(xdf, sub("who_nrevss_", "", tools::file_path_sans_ext(tolower(basename(nm))))) xdf <- setNames(xdf, sub("who_nrevss_", "", tools::file_path_sans_ext(tolower(basename(nm)))))
xdf <- lapply(xdf, function(.x) {
x_cols <- colnames(.x)
if ((("year" %in% x_cols) & ("week" %in% x_cols))) {
.x$wk_date <- suppressWarnings(mmwr_week_to_date(.x$year, .x$week))
} else {
.x$wk_date <- as.Date(NA)
}
if (region == "national") .x$region <- "National"
.x
})
xdf
} }

66
README.Rmd

@ -38,11 +38,15 @@ The following functions are implemented:
- `state_data_providers`: Retrieve metadata about U.S. State CDC Provider Data - `state_data_providers`: Retrieve metadata about U.S. State CDC Provider Data
- `surveillance_areas`: Retrieve a list of valid sub-regions for each surveillance area. - `surveillance_areas`: Retrieve a list of valid sub-regions for each surveillance area.
- `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data - `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data
- `mmwr_week`: Convert a Date to an MMWR day+week+year
- `mmwr_weekday`: Convert a Date to an MMWR weekday
- `mmwr_week_to_date`: Convert an MMWR year+week or year+week+day to a Date object
The following data sets are included: The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables) - `hhs_regions`: HHS Region Table (a data frame with 59 rows and 4 variables)
- `census_regions` Census Region Table (a data frame with 51 rows and 2 variables) - `census_regions`: Census Region Table (a data frame with 51 rows and 2 variables)
- `mmwrid_map`: MMWR ID to Calendar Mappings (it is exported & available, no need to use `data()`)
## Installation ## Installation
@ -90,10 +94,18 @@ glimpse(geographic_spread())
### Laboratory-Confirmed Influenza Hospitalizations ### Laboratory-Confirmed Influenza Hospitalizations
```{r message=FALSE, warning=FALSE} ```{r message=FALSE, warning=FALSE, fig.width=10, fig.height=7.5}
surveillance_areas() surveillance_areas()
glimpse(hospitalizations("flusurv")) glimpse(fs_nat <- hospitalizations("flusurv"))
ggplot(fs_nat, aes(wk_end, rate)) +
geom_line(aes(color=age_label, group=age_label)) +
facet_wrap(~sea_description, scales="free_x") +
scale_color_ipsum(name=NULL) +
labs(x=NULL, y="Rates per 100,000 population",
title="FluSurv-NET :: Entire Network :: All Seasons :: Cumulative Rate") +
theme_ipsum_rc()
glimpse(hospitalizations("eip")) glimpse(hospitalizations("eip"))
@ -127,20 +139,42 @@ walk(c("national", "hhs", "census", "state"), ~{
### Retrieve weekly state-level ILI indicators per-state for a given season ### Retrieve weekly state-level ILI indicators per-state for a given season
```{r message=FALSE, warning=FALSE} ```{r message=FALSE, warning=FALSE, fig.width=10, fig.height=5}
ili_weekly_activity_indicators(2017) ili_weekly_activity_indicators(2017)
ili_weekly_activity_indicators(2015) xdf <- map_df(2008:2017, ili_weekly_activity_indicators)
count(xdf, weekend, ili_activity_label) %>%
complete(weekend, ili_activity_label) %>%
ggplot(aes(weekend, ili_activity_label, fill=n)) +
geom_tile(color="#c2c2c2", size=0.1) +
scale_x_date(expand=c(0,0)) +
viridis::scale_fill_viridis(name="# States", na.value="White") +
labs(x=NULL, y=NULL, title="Weekly ILI Indicators (all states)") +
coord_fixed(100/1) +
theme_ipsum_rc(grid="") +
theme(legend.position="bottom")
``` ```
### Pneumonia and Influenza Mortality Surveillance ### Pneumonia and Influenza Mortality Surveillance
```{r message=FALSE, warning=FALSE} ```{r message=FALSE, warning=FALSE}
pi_mortality("national") (nat_pi <- pi_mortality("national"))
pi_mortality("state") select(nat_pi, wk_end, percent_pni, baseline, threshold) %>%
gather(measure, value, -wk_end) %>%
pi_mortality("region") ggplot(aes(wk_end, value)) +
geom_line(aes(group=measure, color=measure)) +
scale_y_percent() +
scale_color_ipsum(name = NULL, labels=c("Baseline", "Percent P&I", "Threshold")) +
labs(x=NULL, y="% of all deaths due to P&I",
title="Percentage of all deaths due to pneumonia and influenza, National Summary") +
theme_ipsum_rc(grid="XY") +
theme(legend.position="bottom")
(st_pi <- pi_mortality("state"))
(reg_pi <- pi_mortality("region"))
``` ```
### Retrieve metadata about U.S. State CDC Provider Data ### Retrieve metadata about U.S. State CDC Provider Data
@ -152,7 +186,15 @@ state_data_providers()
### Retrieve WHO/NREVSS Surveillance Data ### Retrieve WHO/NREVSS Surveillance Data
```{r message=FALSE, warning=FALSE} ```{r message=FALSE, warning=FALSE}
who_nrevss("national") glimpse(xdat <- who_nrevss("national"))
mutate(xdat$combined_prior_to_2015_16,
percent_positive = percent_positive / 100) %>%
ggplot(aes(wk_date, percent_positive)) +
geom_line() +
scale_y_percent(name="% Positive") +
labs(x=NULL, title="WHO/NREVSS Surveillance Data (National)") +
theme_ipsum_rc(grid="XY")
who_nrevss("hhs") who_nrevss("hhs")

744
README.md

@ -48,9 +48,9 @@ What’s Inside The Tin
The following functions are implemented: The following functions are implemented:
- `agd_ipt`: Age Group Distribution of Influenza Positive Tests - `age_group_distribution`: Age Group Distribution of Influenza
Reported by Public Health Laboratories Positive Tests Reported by Public Health Laboratories
- `cdc_coverage_map`: Retrieve CDC U.S. Coverage Map - `cdc_basemap`: Retrieve CDC U.S. Basemaps
- `geographic_spread`: State and Territorial Epidemiologists Reports - `geographic_spread`: State and Territorial Epidemiologists Reports
of Geographic Spread of Influenza of Geographic Spread of Influenza
- `hospitalizations`: Laboratory-Confirmed Influenza Hospitalizations - `hospitalizations`: Laboratory-Confirmed Influenza Hospitalizations
@ -63,13 +63,19 @@ The following functions are implemented:
- `surveillance_areas`: Retrieve a list of valid sub-regions for each - `surveillance_areas`: Retrieve a list of valid sub-regions for each
surveillance area. surveillance area.
- `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data - `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data
- `mmwr_week`: Convert a Date to an MMWR day+week+year
- `mmwr_weekday`: Convert a Date to an MMWR weekday
- `mmwr_week_to_date`: Convert an MMWR year+week or year+week+day to a
Date object
The following data sets are included: The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 - `hhs_regions`: HHS Region Table (a data frame with 59 rows and 4
variables) variables)
- `census_regions` Census Region Table (a data frame with 51 rows and - `census_regions`: Census Region Table (a data frame with 51 rows and
2 variables) 2 variables)
- `mmwrid_map`: MMWR ID to Calendar Mappings (it is exported &
available, no need to use `data()`)
Installation Installation
------------ ------------
@ -83,6 +89,7 @@ Usage
``` r ``` r
library(cdcfluview) library(cdcfluview)
library(hrbrthemes)
library(tidyverse) library(tidyverse)
# current verison # current verison
@ -94,14 +101,14 @@ packageVersion("cdcfluview")
### Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories ### Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
``` r ``` r
glimpse(agd_ipt()) glimpse(age_group_distribution())
``` ```
## Observations: 36,144 ## Observations: 36,144
## Variables: 13 ## Variables: 16
## $ sea_label <chr> "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "... ## $ sea_label <chr> "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "1997-98", "...
## $ age_label <chr> "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr", "0-4 yr",... ## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ vir_label <chr> "A (Subtyping not Performed)", "A (Subtyping not Performed)", "A (Subtyping not Performed... ## $ vir_label <fctr> A (Subtyping not Performed), A (Subtyping not Performed), A (Subtyping not Performed), A...
## $ count <int> 0, 1, 0, 0, 0, 0, 0, 3, 0, 6, 0, 1, 1, 2, 11, 8, 18, 26, 22, 19, 2, 5, 2, 1, 4, 0, 0, 0, ... ## $ count <int> 0, 1, 0, 0, 0, 0, 0, 3, 0, 6, 0, 1, 1, 2, 11, 8, 18, 26, 22, 19, 2, 5, 2, 1, 4, 0, 0, 0, ...
## $ mmwrid <int> 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880,... ## $ mmwrid <int> 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880,...
## $ seasonid <int> 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 3... ## $ seasonid <int> 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 3...
@ -112,15 +119,48 @@ glimpse(agd_ipt())
## $ vir_description <chr> "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk",... ## $ vir_description <chr> "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk", "A-Unk",...
## $ vir_startmmwrid <int> 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397,... ## $ vir_startmmwrid <int> 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1397,...
## $ vir_endmmwrid <int> 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131,... ## $ vir_endmmwrid <int> 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131,...
## $ wk_start <date> 1997-09-28, 1997-10-05, 1997-10-12, 1997-10-19, 1997-10-26, 1997-11-02, 1997-11-09, 1997...
## $ wk_end <date> 1997-10-04, 1997-10-11, 1997-10-18, 1997-10-25, 1997-11-01, 1997-11-08, 1997-11-15, 1997...
## $ year_wk_num <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11...
### Retrieve CDC U.S. Coverage Map ### Retrieve CDC U.S. Coverage Map
``` r ``` r
plot(cdc_coverage_map()) plot(cdc_basemap("national"))
``` ```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-1.png) ![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-1.png)
``` r
plot(cdc_basemap("hhs"))
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-2.png)
``` r
plot(cdc_basemap("census"))
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-3.png)
``` r
plot(cdc_basemap("states"))
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-4.png)
``` r
plot(cdc_basemap("spread"))
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-5.png)
``` r
plot(cdc_basemap("surv"))
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-6.png)
### State and Territorial Epidemiologists Reports of Geographic Spread of Influenza ### State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
``` r ``` r
@ -168,168 +208,200 @@ surveillance_areas()
## 22 ihsp Utah ## 22 ihsp Utah
``` r ``` r
glimpse(hospitalizations("flusurv")) glimpse(fs_nat <- hospitalizations("flusurv"))
``` ```
## Observations: 1,476 ## Observations: 1,476
## Variables: 20 ## Variables: 14
## $ mmwrid <int> 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559,...
## $ weeknumber <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...
## $ rate <dbl> 0.0, 0.0, 0.0, 0.1, 0.1, 0.2, 0.3, 0.3, 0.4, 0.6, 0.8, 1.3, 1.7, 2.2, 2.8, 3.6, 4.4, 5.4,...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.1, 0.1, 0.1, 0.2, 0.2, 0.4, 0.4, 0.5, 0.5, 0.8, 0.8, 1.0,...
## $ age <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,...
## $ season <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekend <chr> "2010-10-09", "2010-10-16", "2010-10-23", "2010-10-30", "2010-11-06", "2010-11-13", "2010...
## $ weekstart <chr> "2010-10-03", "2010-10-10", "2010-10-17", "2010-10-24", "2010-10-31", "2010-11-07", "2010...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011,...
## $ yearweek <int> 201040, 201041, 201042, 201043, 201044, 201045, 201046, 201047, 201048, 201049, 201050, 2...
## $ seasonid <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekendlabel <chr> "Oct 09, 2010", "Oct 16, 2010", "Oct 23, 2010", "Oct 30, 2010", "Nov 06, 2010", "Nov 13, ...
## $ weekendlabel2 <chr> "Oct-09-2010", "Oct-16-2010", "Oct-23-2010", "Oct-30-2010", "Nov-06-2010", "Nov-13-2010",...
## $ age_label <chr> "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-4...
## $ sea_label <chr> "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "...
## $ sea_description <chr> "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11",...
## $ sea_startweek <int> 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545,...
## $ sea_endweek <int> 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596,...
## $ surveillance_area <chr> "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET",... ## $ surveillance_area <chr> "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET", "FluSurv-NET",...
## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",... ## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",...
## $ year <int> 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,...
## $ season <int> 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 4...
## $ wk_start <date> 2009-08-30, 2009-09-06, 2009-09-13, 2009-09-20, 2009-09-27, 2009-10-04, 2009-10-11, 2009...
## $ wk_end <date> 2009-09-05, 2009-09-12, 2009-09-19, 2009-09-26, 2009-10-03, 2009-10-10, 2009-10-17, 2009...
## $ year_wk_num <int> 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6,...
## $ rate <dbl> 0.5, 2.5, 4.6, 6.7, 10.9, 18.1, 28.3, 39.1, 47.3, 53.3, 57.5, 60.1, 61.6, 62.9, 64.1, 65....
## $ weeklyrate <dbl> 0.5, 2.0, 2.0, 2.1, 4.3, 7.2, 10.2, 10.8, 8.2, 6.0, 4.2, 2.6, 1.5, 1.3, 1.3, 1.0, 1.2, 1....
## $ age <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ sea_label <chr> "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "...
## $ sea_description <chr> "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10",...
## $ mmwrid <int> 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502,...
``` r
ggplot(fs_nat, aes(wk_end, rate)) +
geom_line(aes(color=age_label, group=age_label)) +
facet_wrap(~sea_description, scales="free_x") +
scale_color_ipsum(name=NULL) +
labs(x=NULL, y="Rates per 100,000 population",
title="FluSurv-NET :: Entire Network :: All Seasons :: Cumulative Rate") +
theme_ipsum_rc()
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-7-1.png)
``` r ``` r
glimpse(hospitalizations("eip")) glimpse(hospitalizations("eip"))
``` ```
## Observations: 2,385 ## Observations: 2,385
## Variables: 20 ## Variables: 14
## $ mmwrid <int> 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559,...
## $ weeknumber <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...
## $ rate <dbl> 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.8, 1.1, 1.4, 1.9, 2.3, 2.8, 3.6, 4.5,...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.1, 0.1, 0.1, 0.1, 0.2, 0.4, 0.3, 0.4, 0.4, 0.5, 0.8, 1.0,...
## $ age <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,...
## $ season <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekend <chr> "2010-10-09", "2010-10-16", "2010-10-23", "2010-10-30", "2010-11-06", "2010-11-13", "2010...
## $ weekstart <chr> "2010-10-03", "2010-10-10", "2010-10-17", "2010-10-24", "2010-10-31", "2010-11-07", "2010...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011,...
## $ yearweek <int> 201040, 201041, 201042, 201043, 201044, 201045, 201046, 201047, 201048, 201049, 201050, 2...
## $ seasonid <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekendlabel <chr> "Oct 09, 2010", "Oct 16, 2010", "Oct 23, 2010", "Oct 30, 2010", "Nov 06, 2010", "Nov 13, ...
## $ weekendlabel2 <chr> "Oct-09-2010", "Oct-16-2010", "Oct-23-2010", "Oct-30-2010", "Nov-06-2010", "Nov-13-2010",...
## $ age_label <chr> "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-4...
## $ sea_label <chr> "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "...
## $ sea_description <chr> "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11",...
## $ sea_startweek <int> 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545,...
## $ sea_endweek <int> 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596,...
## $ surveillance_area <chr> "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP"... ## $ surveillance_area <chr> "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP"...
## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",... ## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",...
## $ year <int> 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004,...
## $ season <int> 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 4...
## $ wk_start <date> 2003-09-28, 2003-10-05, 2003-10-12, 2003-10-19, 2003-10-26, 2003-11-02, 2003-11-09, 2003...
## $ wk_end <date> 2003-10-04, 2003-10-11, 2003-10-18, 2003-10-25, 2003-11-01, 2003-11-08, 2003-11-15, 2003...
## $ year_wk_num <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11...
## $ rate <dbl> 0.0, 0.0, 0.0, 0.0, 0.1, 0.7, 3.3, 9.1, 16.9, 28.1, 40.0, 55.6, 69.0, 78.7, 83.1, 86.6, 8...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.0, 0.1, 0.6, 2.7, 5.8, 7.8, 11.2, 11.9, 15.6, 13.4, 9.7, 4.4, 3.4, 1.3, ...
## $ age <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ sea_label <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ sea_description <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ mmwrid <int> 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193,...
``` r ``` r
glimpse(hospitalizations("eip", "Colorado")) glimpse(hospitalizations("eip", "Colorado"))
``` ```
## Observations: 2,385 ## Observations: 2,385
## Variables: 20 ## Variables: 14
## $ mmwrid <int> 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559,...
## $ weeknumber <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...
## $ rate <dbl> 0.0, 0.1, 0.1, 0.1, 0.3, 0.3, 0.4, 0.4, 0.5, 0.6, 0.8, 1.3, 1.8, 2.1, 2.6, 3.4, 4.2, 5.6,...
## $ weeklyrate <dbl> 0.0, 0.1, 0.0, 0.0, 0.2, 0.0, 0.1, 0.1, 0.1, 0.1, 0.2, 0.5, 0.4, 0.4, 0.4, 0.9, 0.8, 1.4,...
## $ age <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,...
## $ season <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekend <chr> "2010-10-09", "2010-10-16", "2010-10-23", "2010-10-30", "2010-11-06", "2010-11-13", "2010...
## $ weekstart <chr> "2010-10-03", "2010-10-10", "2010-10-17", "2010-10-24", "2010-10-31", "2010-11-07", "2010...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011,...
## $ yearweek <int> 201040, 201041, 201042, 201043, 201044, 201045, 201046, 201047, 201048, 201049, 201050, 2...
## $ seasonid <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekendlabel <chr> "Oct 09, 2010", "Oct 16, 2010", "Oct 23, 2010", "Oct 30, 2010", "Nov 06, 2010", "Nov 13, ...
## $ weekendlabel2 <chr> "Oct-09-2010", "Oct-16-2010", "Oct-23-2010", "Oct-30-2010", "Nov-06-2010", "Nov-13-2010",...
## $ age_label <chr> "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-4...
## $ sea_label <chr> "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "...
## $ sea_description <chr> "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11",...
## $ sea_startweek <int> 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545,...
## $ sea_endweek <int> 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596,...
## $ surveillance_area <chr> "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP"... ## $ surveillance_area <chr> "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP", "EIP"...
## $ region <chr> "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colo... ## $ region <chr> "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colorado", "Colo...
## $ year <int> 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004,...
## $ season <int> 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 4...
## $ wk_start <date> 2003-09-28, 2003-10-05, 2003-10-12, 2003-10-19, 2003-10-26, 2003-11-02, 2003-11-09, 2003...
## $ wk_end <date> 2003-10-04, 2003-10-11, 2003-10-18, 2003-10-25, 2003-11-01, 2003-11-08, 2003-11-15, 2003...
## $ year_wk_num <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11...
## $ rate <dbl> 0.0, 0.0, 0.0, 0.0, 0.6, 3.6, 21.2, 57.5, 94.3, 130.6, 146.4, 150.6, 153.0, 157.2, 158.5,...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.0, 0.6, 3.0, 17.5, 36.3, 36.9, 36.3, 15.7, 4.2, 2.4, 4.2, 1.2, 1.2, 1.8,...
## $ age <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ sea_label <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ sea_description <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ mmwrid <int> 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193,...
``` r ``` r
glimpse(hospitalizations("ihsp")) glimpse(hospitalizations("ihsp"))
``` ```
## Observations: 1,476 ## Observations: 1,476
## Variables: 20 ## Variables: 14
## $ mmwrid <int> 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559,...
## $ weeknumber <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...
## $ rate <dbl> 0.0, 0.0, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.6, 0.9, 1.1, 1.9, 2.8, 3.9, 4.9, 6.8, 7.6, 9.0,...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.4, 0.2, 0.8, 0.9, 1.1, 1.0, 2.0, 0.8, 1.4,...
## $ age <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,...
## $ season <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekend <chr> "2010-10-09", "2010-10-16", "2010-10-23", "2010-10-30", "2010-11-06", "2010-11-13", "2010...
## $ weekstart <chr> "2010-10-03", "2010-10-10", "2010-10-17", "2010-10-24", "2010-10-31", "2010-11-07", "2010...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011,...
## $ yearweek <int> 201040, 201041, 201042, 201043, 201044, 201045, 201046, 201047, 201048, 201049, 201050, 2...
## $ seasonid <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekendlabel <chr> "Oct 09, 2010", "Oct 16, 2010", "Oct 23, 2010", "Oct 30, 2010", "Nov 06, 2010", "Nov 13, ...
## $ weekendlabel2 <chr> "Oct-09-2010", "Oct-16-2010", "Oct-23-2010", "Oct-30-2010", "Nov-06-2010", "Nov-13-2010",...
## $ age_label <chr> "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-4...
## $ sea_label <chr> "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "...
## $ sea_description <chr> "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11",...
## $ sea_startweek <int> 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545,...
## $ sea_endweek <int> 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596,...
## $ surveillance_area <chr> "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "... ## $ surveillance_area <chr> "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "...
## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",... ## $ region <chr> "Entire Network", "Entire Network", "Entire Network", "Entire Network", "Entire Network",...
## $ year <int> 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,...
## $ season <int> 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 4...
## $ wk_start <date> 2009-08-30, 2009-09-06, 2009-09-13, 2009-09-20, 2009-09-27, 2009-10-04, 2009-10-11, 2009...
## $ wk_end <date> 2009-09-05, 2009-09-12, 2009-09-19, 2009-09-26, 2009-10-03, 2009-10-10, 2009-10-17, 2009...
## $ year_wk_num <int> 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6,...
## $ rate <dbl> 0.0, 0.4, 3.6, 7.6, 14.0, 25.5, 47.1, 71.8, 87.4, 92.5, 94.9, 96.9, 98.1, 98.9, 100.9, 10...
## $ weeklyrate <dbl> 0.0, 0.4, 3.2, 4.0, 6.4, 11.6, 21.5, 24.7, 15.6, 5.2, 2.4, 2.0, 1.2, 0.8, 2.0, 1.2, 1.6, ...
## $ age <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ sea_label <chr> "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "...
## $ sea_description <chr> "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10",...
## $ mmwrid <int> 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502,...
``` r ``` r
glimpse(hospitalizations("ihsp", "Oklahoma")) glimpse(hospitalizations("ihsp", "Oklahoma"))
``` ```
## Observations: 390 ## Observations: 390
## Variables: 20 ## Variables: 14
## $ mmwrid <int> 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559,...
## $ weeknumber <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...
## $ rate <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.4, 0.7, 0.7, 1.3, 2.2, 2.5, 3.4, 4.5, 5.8, 7.6,...
## $ weeklyrate <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.2, 0.2, 0.0, 0.7, 0.9, 0.2, 0.9, 1.1, 1.3, 1.8,...
## $ age <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,...
## $ season <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekend <chr> "2010-10-09", "2010-10-16", "2010-10-23", "2010-10-30", "2010-11-06", "2010-11-13", "2010...
## $ weekstart <chr> "2010-10-03", "2010-10-10", "2010-10-17", "2010-10-24", "2010-10-31", "2010-11-07", "2010...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011,...
## $ yearweek <int> 201040, 201041, 201042, 201043, 201044, 201045, 201046, 201047, 201048, 201049, 201050, 2...
## $ seasonid <int> 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5...
## $ weekendlabel <chr> "Oct 09, 2010", "Oct 16, 2010", "Oct 23, 2010", "Oct 30, 2010", "Nov 06, 2010", "Nov 13, ...
## $ weekendlabel2 <chr> "Oct-09-2010", "Oct-16-2010", "Oct-23-2010", "Oct-30-2010", "Nov-06-2010", "Nov-13-2010",...
## $ age_label <chr> "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-49 yr", "18-4...
## $ sea_label <chr> "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "2010-11", "...
## $ sea_description <chr> "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11", "Season 2010-11",...
## $ sea_startweek <int> 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545,...
## $ sea_endweek <int> 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596, 2596,...
## $ surveillance_area <chr> "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "... ## $ surveillance_area <chr> "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "IHSP", "...
## $ region <chr> "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Okla... ## $ region <chr> "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Oklahoma", "Okla...
## $ year <int> 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,...
## $ season <int> 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 4...
## $ wk_start <date> 2009-08-30, 2009-09-06, 2009-09-13, 2009-09-20, 2009-09-27, 2009-10-04, 2009-10-11, 2009...
## $ wk_end <date> 2009-09-05, 2009-09-12, 2009-09-19, 2009-09-26, 2009-10-03, 2009-10-10, 2009-10-17, 2009...
## $ year_wk_num <int> 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6,...
## $ rate <dbl> 0.0, 1.3, 10.8, 21.5, 40.4, 63.3, 88.9, 106.4, 115.8, 121.2, 125.2, 125.2, 126.6, 127.9, ...
## $ weeklyrate <dbl> 0.0, 1.3, 9.4, 10.8, 18.9, 22.9, 25.6, 17.5, 9.4, 5.4, 4.0, 0.0, 1.3, 1.3, 2.7, 1.3, 5.4,...
## $ age <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ age_label <fctr> 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, 0-4 yr, ...
## $ sea_label <chr> "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "2009-10", "...
## $ sea_description <chr> "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10", "Season 2009-10",...
## $ mmwrid <int> 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502,...
### Retrieve ILINet Surveillance Data ### Retrieve ILINet Surveillance Data
``` r ``` r
ilinet("national") walk(c("national", "hhs", "census", "state"), ~{
ili_df <- ilinet(region = .x)
print(glimpse(ili_df))
ggplot(ili_df, aes(week_start, unweighted_ili, group=region, color=region)) +
geom_line() +
viridis::scale_color_viridis(discrete=TRUE) +
labs(x=NULL, y="Unweighted ILI", title=ili_df$region_type[1]) +
theme_ipsum_rc(grid="XY") +
theme(legend.position = "none") -> gg
print(gg)
})
``` ```
## # A tibble: 1,048 x 15 ## Observations: 1,048
## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 age_50_64 age_65 ## Variables: 16
## <chr> <chr> <int> <int> <dbl> <dbl> <int> <chr> <chr> <int> <chr> <int> ## $ region_type <chr> "National", "National", "National", "National", "National", "National", "National", "Natio...
## 1 National <NA> 1997 40 1.10148 1.21686 179 <NA> 157 205 <NA> 29 ## $ region <chr> "National", "National", "National", "National", "National", "National", "National", "Natio...
## 2 National <NA> 1997 41 1.20007 1.28064 199 <NA> 151 242 <NA> 23 ## $ year <int> 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1998, ...
## 3 National <NA> 1997 42 1.37876 1.23906 228 <NA> 153 266 <NA> 34 ## $ week <int> 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,...
## 4 National <NA> 1997 43 1.19920 1.14473 188 <NA> 193 236 <NA> 36 ## $ weighted_ili <dbl> 1.101480, 1.200070, 1.378760, 1.199200, 1.656180, 1.413260, 1.986800, 2.447490, 1.739010, ...
## 5 National <NA> 1997 44 1.65618 1.26112 217 <NA> 162 280 <NA> 41 ## $ unweighted_ili <dbl> 1.216860, 1.280640, 1.239060, 1.144730, 1.261120, 1.282750, 1.445790, 1.647960, 1.675170, ...
## 6 National <NA> 1997 45 1.41326 1.28275 178 <NA> 148 281 <NA> 48 ## $ age_0_4 <dbl> 179, 199, 228, 188, 217, 178, 294, 288, 268, 299, 346, 348, 510, 579, 639, 690, 856, 824, ...
## 7 National <NA> 1997 46 1.98680 1.44579 294 <NA> 240 328 <NA> 70 ## $ age_25_49 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## 8 National <NA> 1997 47 2.44749 1.64796 288 <NA> 293 456 <NA> 63 ## $ age_25_64 <dbl> 157, 151, 153, 193, 162, 148, 240, 293, 206, 282, 268, 235, 404, 584, 759, 654, 679, 817, ...
## 9 National <NA> 1997 48 1.73901 1.67517 268 <NA> 206 343 <NA> 69 ## $ age_5_24 <dbl> 205, 242, 266, 236, 280, 281, 328, 456, 343, 415, 388, 362, 492, 576, 810, 1121, 1440, 160...
## 10 National <NA> 1997 49 1.93919 1.61739 299 <NA> 282 415 <NA> 102 ## $ age_50_64 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## # ... with 1,038 more rows, and 3 more variables: ilitotal <int>, num_of_providers <int>, total_patients <int> ## $ age_65 <dbl> 29, 23, 34, 36, 41, 48, 70, 63, 69, 102, 81, 59, 113, 207, 207, 148, 151, 196, 233, 146, 1...
## $ ilitotal <dbl> 570, 615, 681, 653, 700, 655, 932, 1100, 886, 1098, 1083, 1004, 1519, 1946, 2415, 2613, 31...
``` r ## $ num_of_providers <dbl> 192, 191, 219, 213, 213, 195, 248, 256, 252, 253, 242, 190, 251, 250, 254, 255, 245, 245, ...
ilinet("hhs") ## $ total_patients <dbl> 46842, 48023, 54961, 57044, 55506, 51062, 64463, 66749, 52890, 67887, 61314, 47719, 48429,...
``` ## $ week_start <date> 1997-10-06, 1997-10-13, 1997-10-20, 1997-10-27, 1997-11-03, 1997-11-10, 1997-11-17, 1997-...
## # A tibble: 1,048 x 16
## # A tibble: 10,480 x 15 ## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 age_50_64 age_65
## <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 National National 1997 40 1.10148 1.21686 179 NA 157 205 NA 29
## 2 National National 1997 41 1.20007 1.28064 199 NA 151 242 NA 23
## 3 National National 1997 42 1.37876 1.23906 228 NA 153 266 NA 34
## 4 National National 1997 43 1.19920 1.14473 188 NA 193 236 NA 36
## 5 National National 1997 44 1.65618 1.26112 217 NA 162 280 NA 41
## 6 National National 1997 45 1.41326 1.28275 178 NA 148 281 NA 48
## 7 National National 1997 46 1.98680 1.44579 294 NA 240 328 NA 70
## 8 National National 1997 47 2.44749 1.64796 288 NA 293 456 NA 63
## 9 National National 1997 48 1.73901 1.67517 268 NA 206 343 NA 69
## 10 National National 1997 49 1.93919 1.61739 299 NA 282 415 NA 102
## # ... with 1,038 more rows, and 4 more variables: ilitotal <dbl>, num_of_providers <dbl>, total_patients <dbl>,
## # week_start <date>
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-1.png)
## Observations: 10,480
## Variables: 16
## $ region_type <chr> "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions", ...
## $ region <fctr> Region 1, Region 2, Region 3, Region 4, Region 5, Region 6, Region 7, Region 8, Region 9,...
## $ year <int> 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, ...
## $ week <int> 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42...
## $ weighted_ili <dbl> 0.498535, 0.374963, 1.354280, 0.400338, 1.229260, 1.018980, 0.871791, 0.516017, 1.807610, ...
## $ unweighted_ili <dbl> 0.623848, 0.384615, 1.341720, 0.450010, 0.901266, 0.747384, 1.152860, 0.422654, 2.258780, ...
## $ age_0_4 <dbl> 15, 0, 6, 12, 31, 2, 0, 2, 80, 31, 14, 0, 4, 21, 36, 2, 0, 0, 103, 19, 35, 0, 3, 19, 66, 2...
## $ age_25_49 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_25_64 <dbl> 7, 3, 7, 23, 24, 1, 4, 0, 76, 12, 14, 2, 19, 7, 23, 2, 0, 1, 76, 7, 15, 0, 17, 15, 29, 2, ...
## $ age_5_24 <dbl> 22, 0, 15, 11, 30, 2, 18, 3, 74, 30, 29, 0, 16, 14, 41, 2, 13, 8, 84, 35, 35, 0, 24, 18, 7...
## $ age_50_64 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_65 <dbl> 0, 0, 4, 0, 4, 0, 5, 0, 13, 3, 0, 0, 3, 2, 4, 0, 2, 0, 11, 1, 0, 1, 2, 2, 16, 0, 2, 0, 9, ...
## $ ilitotal <dbl> 44, 3, 32, 46, 89, 5, 27, 5, 243, 76, 57, 2, 42, 44, 104, 6, 15, 9, 274, 62, 85, 1, 46, 54...
## $ num_of_providers <dbl> 32, 7, 16, 29, 49, 4, 14, 5, 23, 13, 29, 7, 17, 31, 48, 4, 14, 6, 23, 12, 40, 7, 15, 33, 6...
## $ total_patients <dbl> 7053, 780, 2385, 10222, 9875, 669, 2342, 1183, 10758, 1575, 6987, 872, 2740, 11310, 9618, ...
## $ week_start <date> 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-...
## # A tibble: 10,480 x 16
## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 age_50_64 age_65 ## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 age_50_64 age_65
## <chr> <chr> <int> <int> <dbl> <dbl> <int> <int> <int> <int> <int> <int> ## <chr> <fctr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 HHS Regions Region 1 1997 40 0.498535 0.623848 15 NA 7 22 NA 0 ## 1 HHS Regions Region 1 1997 40 0.498535 0.623848 15 NA 7 22 NA 0
## 2 HHS Regions Region 2 1997 40 0.374963 0.384615 0 NA 3 0 NA 0 ## 2 HHS Regions Region 2 1997 40 0.374963 0.384615 0 NA 3 0 NA 0
## 3 HHS Regions Region 3 1997 40 1.354280 1.341720 6 NA 7 15 NA 4 ## 3 HHS Regions Region 3 1997 40 1.354280 1.341720 6 NA 7 15 NA 4
@ -340,47 +412,82 @@ ilinet("hhs")
## 8 HHS Regions Region 8 1997 40 0.516017 0.422654 2 NA 0 3 NA 0 ## 8 HHS Regions Region 8 1997 40 0.516017 0.422654 2 NA 0 3 NA 0
## 9 HHS Regions Region 9 1997 40 1.807610 2.258780 80 NA 76 74 NA 13 ## 9 HHS Regions Region 9 1997 40 1.807610 2.258780 80 NA 76 74 NA 13
## 10 HHS Regions Region 10 1997 40 4.743520 4.825400 31 NA 12 30 NA 3 ## 10 HHS Regions Region 10 1997 40 4.743520 4.825400 31 NA 12 30 NA 3
## # ... with 10,470 more rows, and 3 more variables: ilitotal <int>, num_of_providers <int>, total_patients <int> ## # ... with 10,470 more rows, and 4 more variables: ilitotal <dbl>, num_of_providers <dbl>, total_patients <dbl>,
## # week_start <date>
``` r
ilinet("census") ![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-2.png)
```
## Observations: 9,432
## # A tibble: 9,432 x 15 ## Variables: 16
## $ region_type <chr> "Census Regions", "Census Regions", "Census Regions", "Census Regions", "Census Regions", ...
## $ region <chr> "New England", "Mid-Atlantic", "East North Central", "West North Central", "South Atlantic...
## $ year <int> 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, ...
## $ week <int> 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42...
## $ weighted_ili <dbl> 0.4985350, 0.8441440, 0.7924860, 1.7640500, 0.5026620, 0.0542283, 1.0189800, 2.2587800, 2....
## $ unweighted_ili <dbl> 0.6238480, 1.3213800, 0.8187380, 1.2793900, 0.7233800, 0.0688705, 0.7473840, 2.2763300, 3....
## $ age_0_4 <dbl> 15, 4, 28, 3, 14, 0, 2, 87, 26, 14, 4, 36, 0, 21, 0, 2, 93, 29, 35, 3, 65, 1, 19, 0, 2, 84...
## $ age_25_49 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_25_64 <dbl> 7, 8, 20, 8, 22, 3, 1, 71, 17, 14, 13, 23, 1, 14, 1, 2, 72, 11, 15, 11, 27, 5, 21, 0, 2, 5...
## $ age_5_24 <dbl> 22, 12, 28, 20, 14, 0, 2, 71, 36, 29, 8, 39, 18, 22, 0, 2, 80, 44, 35, 16, 74, 9, 24, 2, 2...
## $ age_50_64 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_65 <dbl> 0, 4, 3, 6, 0, 0, 0, 15, 1, 0, 2, 2, 4, 3, 0, 0, 10, 2, 0, 3, 12, 6, 2, 0, 0, 9, 2, 0, 1, ...
## $ ilitotal <dbl> 44, 28, 79, 37, 50, 3, 5, 244, 80, 57, 27, 100, 23, 60, 1, 6, 255, 86, 85, 33, 178, 21, 66...
## $ num_of_providers <dbl> 32, 13, 47, 17, 30, 9, 4, 16, 24, 29, 13, 46, 17, 32, 10, 4, 17, 23, 40, 12, 62, 16, 33, 1...
## $ total_patients <dbl> 7053, 2119, 9649, 2892, 6912, 4356, 669, 10719, 2473, 6987, 2384, 9427, 2823, 7591, 4947, ...
## $ week_start <date> 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-10-06, 1997-...
## # A tibble: 9,432 x 16
## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 ## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24
## <chr> <chr> <int> <int> <dbl> <dbl> <int> <chr> <chr> <int> ## <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Census Regions New England 1997 40 0.4985350 0.6238480 15 <NA> 7 22 ## 1 Census Regions New England 1997 40 0.4985350 0.6238480 15 NA 7 22
## 2 Census Regions Mid-Atlantic 1997 40 0.8441440 1.3213800 4 <NA> 8 12 ## 2 Census Regions Mid-Atlantic 1997 40 0.8441440 1.3213800 4 NA 8 12
## 3 Census Regions East North Central 1997 40 0.7924860 0.8187380 28 <NA> 20 28 ## 3 Census Regions East North Central 1997 40 0.7924860 0.8187380 28 NA 20 28
## 4 Census Regions West North Central 1997 40 1.7640500 1.2793900 3 <NA> 8 20 ## 4 Census Regions West North Central 1997 40 1.7640500 1.2793900 3 NA 8 20
## 5 Census Regions South Atlantic 1997 40 0.5026620 0.7233800 14 <NA> 22 14 ## 5 Census Regions South Atlantic 1997 40 0.5026620 0.7233800 14 NA 22 14
## 6 Census Regions East South Central 1997 40 0.0542283 0.0688705 0 <NA> 3 0 ## 6 Census Regions East South Central 1997 40 0.0542283 0.0688705 0 NA 3 0
## 7 Census Regions West South Central 1997 40 1.0189800 0.7473840 2 <NA> 1 2 ## 7 Census Regions West South Central 1997 40 1.0189800 0.7473840 2 NA 1 2
## 8 Census Regions Mountain 1997 40 2.2587800 2.2763300 87 <NA> 71 71 ## 8 Census Regions Mountain 1997 40 2.2587800 2.2763300 87 NA 71 71
## 9 Census Regions Pacific 1997 40 2.0488300 3.2349400 26 <NA> 17 36 ## 9 Census Regions Pacific 1997 40 2.0488300 3.2349400 26 NA 17 36
## 10 Census Regions New England 1997 41 0.6426690 0.8158010 14 <NA> 14 29 ## 10 Census Regions New England 1997 41 0.6426690 0.8158010 14 NA 14 29
## # ... with 9,422 more rows, and 5 more variables: age_50_64 <chr>, age_65 <int>, ilitotal <int>, ## # ... with 9,422 more rows, and 6 more variables: age_50_64 <dbl>, age_65 <dbl>, ilitotal <dbl>,
## # num_of_providers <int>, total_patients <int> ## # num_of_providers <dbl>, total_patients <dbl>, week_start <date>
``` r ![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-3.png)
ilinet("state")
``` ## Observations: 19,718
## Variables: 16
## # A tibble: 19,718 x 15 ## $ region_type <chr> "States", "States", "States", "States", "States", "States", "States", "States", "States", ...
## $ region <chr> "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Dela...
## $ year <int> 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, ...
## $ week <int> 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40...
## $ weighted_ili <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ unweighted_ili <dbl> 2.1347700, 0.8751460, 0.6747210, 0.6960560, 1.9541200, 0.6606840, 0.0783085, 0.1001250, 2....
## $ age_0_4 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_25_49 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_25_64 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_5_24 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_50_64 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ age_65 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ ilitotal <dbl> 249, 15, 172, 18, 632, 134, 3, 4, 73, NA, 647, 20, 19, 505, 65, 10, 39, 19, NA, 22, 117, 1...
## $ num_of_providers <dbl> 35, 7, 49, 15, 112, 14, 12, 13, 4, NA, 62, 18, 12, 74, 44, 6, 40, 14, NA, 30, 17, 56, 47, ...
## $ total_patients <dbl> 11664, 1714, 25492, 2586, 32342, 20282, 3831, 3995, 2599, NA, 40314, 1943, 4579, 39390, 12...
## $ week_start <date> 2010-10-04, 2010-10-04, 2010-10-04, 2010-10-04, 2010-10-04, 2010-10-04, 2010-10-04, 2010-...
## # A tibble: 19,718 x 16
## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24 ## region_type region year week weighted_ili unweighted_ili age_0_4 age_25_49 age_25_64 age_5_24
## <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> <chr> ## <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 States Alabama 2010 40 <NA> 2.13477 <NA> <NA> <NA> <NA> ## 1 States Alabama 2010 40 NA 2.1347700 NA NA NA NA
## 2 States Alaska 2010 40 <NA> 0.875146 <NA> <NA> <NA> <NA> ## 2 States Alaska 2010 40 NA 0.8751460 NA NA NA NA
## 3 States Arizona 2010 40 <NA> 0.674721 <NA> <NA> <NA> <NA> ## 3 States Arizona 2010 40 NA 0.6747210 NA NA NA NA
## 4 States Arkansas 2010 40 <NA> 0.696056 <NA> <NA> <NA> <NA> ## 4 States Arkansas 2010 40 NA 0.6960560 NA NA NA NA
## 5 States California 2010 40 <NA> 1.95412 <NA> <NA> <NA> <NA> ## 5 States California 2010 40 NA 1.9541200 NA NA NA NA
## 6 States Colorado 2010 40 <NA> 0.660684 <NA> <NA> <NA> <NA> ## 6 States Colorado 2010 40 NA 0.6606840 NA NA NA NA
## 7 States Connecticut 2010 40 <NA> 0.0783085 <NA> <NA> <NA> <NA> ## 7 States Connecticut 2010 40 NA 0.0783085 NA NA NA NA
## 8 States Delaware 2010 40 <NA> 0.100125 <NA> <NA> <NA> <NA> ## 8 States Delaware 2010 40 NA 0.1001250 NA NA NA NA
## 9 States District of Columbia 2010 40 <NA> 2.80877 <NA> <NA> <NA> <NA> ## 9 States District of Columbia 2010 40 NA 2.8087700 NA NA NA NA
## 10 States Florida 2010 40 <NA> <NA> <NA> <NA> <NA> <NA> ## 10 States Florida 2010 40 NA NA NA NA NA NA
## # ... with 19,708 more rows, and 5 more variables: age_50_64 <chr>, age_65 <chr>, ilitotal <chr>, ## # ... with 19,708 more rows, and 6 more variables: age_50_64 <dbl>, age_65 <dbl>, ilitotal <dbl>,
## # num_of_providers <chr>, total_patients <chr> ## # num_of_providers <dbl>, total_patients <dbl>, week_start <date>
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-4.png)
### Retrieve weekly state-level ILI indicators per-state for a given season ### Retrieve weekly state-level ILI indicators per-state for a given season
@ -404,48 +511,62 @@ ili_weekly_activity_indicators(2017)
## # ... with 206 more rows ## # ... with 206 more rows
``` r ``` r
ili_weekly_activity_indicators(2015) xdf <- map_df(2008:2017, ili_weekly_activity_indicators)
count(xdf, weekend, ili_activity_label) %>%
complete(weekend, ili_activity_label) %>%
ggplot(aes(weekend, ili_activity_label, fill=n)) +
geom_tile(color="#c2c2c2", size=0.1) +
scale_x_date(expand=c(0,0)) +
viridis::scale_fill_viridis(name="# States", na.value="White") +
labs(x=NULL, y=NULL, title="Weekly ILI Indicators (all states)") +
coord_fixed(100/1) +
theme_ipsum_rc(grid="") +
theme(legend.position="bottom")
``` ```
## # A tibble: 2,807 x 9 ![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-9-1.png)
## statename ili_activity_label ili_activity_group statefips stateabbr weekend weeknumber year seasonid
## <chr> <fctr> <chr> <chr> <chr> <date> <int> <int> <int>
## 1 Alabama Level 1 Minimal 01 AL 2015-10-10 40 2015 55
## 2 Alabama Level 1 Minimal 01 AL 2015-10-17 41 2015 55
## 3 Alabama Level 1 Minimal 01 AL 2015-10-24 42 2015 55
## 4 Alabama Level 1 Minimal 01 AL 2015-10-31 43 2015 55
## 5 Alabama Level 1 Minimal 01 AL 2015-11-07 44 2015 55
## 6 Alabama Level 1 Minimal 01 AL 2015-11-14 45 2015 55
## 7 Alabama Level 1 Minimal 01 AL 2015-11-21 46 2015 55
## 8 Alabama Level 3 Minimal 01 AL 2015-11-28 47 2015 55
## 9 Alabama Level 1 Minimal 01 AL 2015-12-05 48 2015 55
## 10 Alabama Level 1 Minimal 01 AL 2015-12-12 49 2015 55
## # ... with 2,797 more rows
### Pneumonia and Influenza Mortality Surveillance ### Pneumonia and Influenza Mortality Surveillance
``` r ``` r
pi_mortality("national") (nat_pi <- pi_mortality("national"))
``` ```
## # A tibble: 419 x 19 ## # A tibble: 419 x 19
## seasonid baseline threshold percent_pni percent_complete number_influenza number_pneumonia all_deaths total_pni ## seasonid baseline threshold percent_pni percent_complete number_influenza number_pneumonia all_deaths total_pni
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 57 5.8 6.1 0.054 0.763 10 1962 36283 1972 ## 1 57 0.058 0.061 0.054 0.763 10 1962 36283 1972
## 2 57 5.8 6.2 0.056 0.675 10 1795 32107 1805 ## 2 57 0.058 0.062 0.056 0.675 10 1795 32107 1805
## 3 56 5.9 6.3 0.059 1.000 18 3022 51404 3040 ## 3 56 0.059 0.063 0.059 1.000 18 3022 51404 3040
## 4 56 6.0 6.3 0.061 1.000 11 3193 52130 3204 ## 4 56 0.060 0.063 0.061 1.000 11 3193 52130 3204
## 5 56 6.1 6.4 0.062 1.000 7 3178 51443 3185 ## 5 56 0.061 0.064 0.062 1.000 7 3178 51443 3185
## 6 56 6.2 6.5 0.061 1.000 17 3129 51865 3146 ## 6 56 0.062 0.065 0.061 1.000 17 3129 51865 3146
## 7 56 6.3 6.6 0.060 1.000 16 3099 51753 3115 ## 7 56 0.063 0.066 0.060 1.000 16 3099 51753 3115
## 8 56 6.4 6.7 0.061 1.000 19 3208 52541 3227 ## 8 56 0.064 0.067 0.061 1.000 19 3208 52541 3227
## 9 56 6.5 6.8 0.060 1.000 7 3192 53460 3199 ## 9 56 0.065 0.068 0.060 1.000 7 3192 53460 3199
## 10 56 6.6 6.9 0.062 1.000 22 3257 53163 3279 ## 10 56 0.066 0.069 0.062 1.000 22 3257 53163 3279
## # ... with 409 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>, ## # ... with 409 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>,
## # weekend <date>, weekstart <date>, year <int>, yearweek <int>, coverage_area <chr>, region_name <chr>, callout <chr> ## # wk_start <date>, wk_end <date>, year_wk_num <int>, mmwrid <chr>, coverage_area <chr>, region_name <chr>,
## # callout <chr>
``` r ``` r
pi_mortality("state") select(nat_pi, wk_end, percent_pni, baseline, threshold) %>%
gather(measure, value, -wk_end) %>%
ggplot(aes(wk_end, value)) +
geom_line(aes(group=measure, color=measure)) +
scale_y_percent() +
scale_color_ipsum(name = NULL, labels=c("Baseline", "Percent P&I", "Threshold")) +
labs(x=NULL, y="% of all deaths due to P&I",
title="Percentage of all deaths due to pneumonia and influenza, National Summary") +
theme_ipsum_rc(grid="XY") +
theme(legend.position="bottom")
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-10-1.png)
``` r
(st_pi <- pi_mortality("state"))
``` ```
## # A tibble: 21,788 x 19 ## # A tibble: 21,788 x 19
@ -462,27 +583,29 @@ pi_mortality("state")
## 9 57 NA NA 0.065 0.774 1 228 3510 229 ## 9 57 NA NA 0.065 0.774 1 228 3510 229
## 10 57 NA NA 0.059 0.758 2 201 3438 203 ## 10 57 NA NA 0.059 0.758 2 201 3438 203
## # ... with 21,778 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>, ## # ... with 21,778 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>,
## # weekend <date>, weekstart <date>, year <int>, yearweek <int>, coverage_area <chr>, region_name <chr>, callout <chr> ## # wk_start <date>, wk_end <date>, year_wk_num <int>, mmwrid <chr>, coverage_area <chr>, region_name <chr>,
## # callout <chr>
``` r ``` r
pi_mortality("region") (reg_pi <- pi_mortality("region"))
``` ```
## # A tibble: 4,190 x 19 ## # A tibble: 4,190 x 19
## seasonid baseline threshold percent_pni percent_complete number_influenza number_pneumonia all_deaths total_pni ## seasonid baseline threshold percent_pni percent_complete number_influenza number_pneumonia all_deaths total_pni
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 57 6.0 6.7 0.051 0.735 0 85 1683 85 ## 1 57 0.060 0.067 0.051 0.735 0 85 1683 85
## 2 57 6.1 6.8 0.060 0.701 0 96 1605 96 ## 2 57 0.061 0.068 0.060 0.701 0 96 1605 96
## 3 57 6.0 6.5 0.061 0.608 1 154 2524 155 ## 3 57 0.060 0.065 0.061 0.608 1 154 2524 155
## 4 57 6.0 6.6 0.063 0.602 1 157 2497 158 ## 4 57 0.060 0.066 0.063 0.602 1 157 2497 158
## 5 57 5.3 5.8 0.045 0.511 1 115 2575 116 ## 5 57 0.053 0.058 0.045 0.511 1 115 2575 116
## 6 57 5.4 5.9 0.045 0.440 1 98 2215 99 ## 6 57 0.054 0.059 0.045 0.440 1 98 2215 99
## 7 57 5.6 6.0 0.051 0.744 3 394 7753 397 ## 7 57 0.056 0.060 0.051 0.744 3 394 7753 397
## 8 57 5.7 6.1 0.052 0.651 1 354 6778 355 ## 8 57 0.057 0.061 0.052 0.651 1 354 6778 355
## 9 57 5.5 5.9 0.052 0.914 1 403 7701 404 ## 9 57 0.055 0.059 0.052 0.914 1 403 7701 404
## 10 57 5.6 6.0 0.054 0.799 4 358 6733 362 ## 10 57 0.056 0.060 0.054 0.799 4 358 6733 362
## # ... with 4,180 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>, ## # ... with 4,180 more rows, and 10 more variables: weeknumber <chr>, geo_description <chr>, age_label <chr>,
## # weekend <date>, weekstart <date>, year <int>, yearweek <int>, coverage_area <chr>, region_name <chr>, callout <chr> ## # wk_start <date>, wk_end <date>, year_wk_num <int>, mmwrid <chr>, coverage_area <chr>, region_name <chr>,
## # callout <chr>
### Retrieve metadata about U.S. State CDC Provider Data ### Retrieve metadata about U.S. State CDC Provider Data
@ -508,63 +631,70 @@ state_data_providers()
### Retrieve WHO/NREVSS Surveillance Data ### Retrieve WHO/NREVSS Surveillance Data
``` r ``` r
who_nrevss("national") glimpse(xdat <- who_nrevss("national"))
``` ```
## $combined_prior_to_2015_16 ## List of 3
## # A tibble: 940 x 13 ## $ combined_prior_to_2015_16:Classes 'tbl_df', 'tbl' and 'data.frame': 940 obs. of 14 variables:
## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3 a_subtyping_not_performed ## ..$ region_type : chr [1:940] "National" "National" "National" "National" ...
## <chr> <chr> <int> <int> <int> <dbl> <int> <int> <int> <int> ## ..$ region : chr [1:940] "National" "National" "National" "National" ...
## 1 National <NA> 1997 40 1291 0.000000 0 0 0 0 ## ..$ year : int [1:940] 1997 1997 1997 1997 1997 1997 1997 1997 1997 1997 ...
## 2 National <NA> 1997 41 1513 0.727032 0 0 0 11 ## ..$ week : int [1:940] 40 41 42 43 44 45 46 47 48 49 ...
## 3 National <NA> 1997 42 1552 1.095360 0 0 3 13 ## ..$ total_specimens : int [1:940] 1291 1513 1552 1669 1897 2106 2204 2533 2242 2607 ...
## 4 National <NA> 1997 43 1669 0.419413 0 0 0 7 ## ..$ percent_positive : num [1:940] 0 0.727 1.095 0.419 0.527 ...
## 5 National <NA> 1997 44 1897 0.527148 0 0 9 1 ## ..$ a_2009_h1n1 : int [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## 6 National <NA> 1997 45 2106 0.284900 0 0 0 6 ## ..$ a_h1 : int [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## 7 National <NA> 1997 46 2204 0.362976 0 0 3 4 ## ..$ a_h3 : int [1:940] 0 0 3 0 9 0 3 5 14 11 ...
## 8 National <NA> 1997 47 2533 0.908014 0 0 5 17 ## ..$ a_subtyping_not_performed: int [1:940] 0 11 13 7 1 6 4 17 22 28 ...
## 9 National <NA> 1997 48 2242 1.650310 0 0 14 22 ## ..$ a_unable_to_subtype : int [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## 10 National <NA> 1997 49 2607 1.534330 0 0 11 28 ## ..$ b : int [1:940] 0 0 1 0 0 0 1 1 1 1 ...
## # ... with 930 more rows, and 3 more variables: a_unable_to_subtype <int>, b <int>, h3n2v <int> ## ..$ h3n2v : int [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## ## ..$ wk_date : Date[1:940], format: "1997-09-28" "1997-10-05" "1997-10-12" "1997-10-19" ...
## $public_health_labs ## $ public_health_labs :Classes 'tbl_df', 'tbl' and 'data.frame': 108 obs. of 13 variables:
## # A tibble: 108 x 12 ## ..$ region_type : chr [1:108] "National" "National" "National" "National" ...
## region_type region year week total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed b bvic byam h3n2v ## ..$ region : chr [1:108] "National" "National" "National" "National" ...
## <chr> <chr> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> ## ..$ year : int [1:108] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 ...
## 1 National <NA> 2015 40 1139 4 65 2 10 0 1 0 ## ..$ week : int [1:108] 40 41 42 43 44 45 46 47 48 49 ...
## 2 National <NA> 2015 41 1152 5 41 2 7 3 0 0 ## ..$ total_specimens : int [1:108] 1139 1152 1198 1244 1465 1393 1458 1157 1550 1518 ...
## 3 National <NA> 2015 42 1198 10 50 1 8 3 2 0 ## ..$ a_2009_h1n1 : int [1:108] 4 5 10 9 4 11 17 17 27 38 ...
## 4 National <NA> 2015 43 1244 9 31 4 9 1 4 0 ## ..$ a_h3 : int [1:108] 65 41 50 31 23 34 42 24 36 37 ...
## 5 National <NA> 2015 44 1465 4 23 4 9 1 4 0 ## ..$ a_subtyping_not_performed: int [1:108] 2 2 1 4 4 1 1 0 3 3 ...
## 6 National <NA> 2015 45 1393 11 34 1 10 4 2 0 ## ..$ b : int [1:108] 10 7 8 9 9 10 4 4 9 11 ...
## 7 National <NA> 2015 46 1458 17 42 1 4 0 4 0 ## ..$ bvic : int [1:108] 0 3 3 1 1 4 0 3 3 2 ...
## 8 National <NA> 2015 47 1157 17 24 0 4 3 9 0 ## ..$ byam : int [1:108] 1 0 2 4 4 2 4 9 12 11 ...
## 9 National <NA> 2015 48 1550 27 36 3 9 3 12 0 ## ..$ h3n2v : int [1:108] 0 0 0 0 0 0 0 0 0 0 ...
## 10 National <NA> 2015 49 1518 38 37 3 11 2 11 0 ## ..$ wk_date : Date[1:108], format: "2015-10-04" "2015-10-11" "2015-10-18" "2015-10-25" ...
## # ... with 98 more rows ## $ clinical_labs :Classes 'tbl_df', 'tbl' and 'data.frame': 108 obs. of 11 variables:
## ## ..$ region_type : chr [1:108] "National" "National" "National" "National" ...
## $clinical_labs ## ..$ region : chr [1:108] "National" "National" "National" "National" ...
## # A tibble: 108 x 10 ## ..$ year : int [1:108] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 ...
## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b ## ..$ week : int [1:108] 40 41 42 43 44 45 46 47 48 49 ...
## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl> ## ..$ total_specimens : int [1:108] 12029 13111 13441 13537 14687 15048 15250 15234 16201 16673 ...
## 1 National <NA> 2015 40 12029 84 43 1.05578 0.698312 0.357469 ## ..$ total_a : int [1:108] 84 116 97 98 97 122 84 119 145 140 ...
## 2 National <NA> 2015 41 13111 116 54 1.29662 0.884753 0.411868 ## ..$ total_b : int [1:108] 43 54 52 52 68 86 98 92 81 106 ...
## 3 National <NA> 2015 42 13441 97 52 1.10855 0.721672 0.386876 ## ..$ percent_positive: num [1:108] 1.06 1.3 1.11 1.11 1.12 ...
## 4 National <NA> 2015 43 13537 98 52 1.10807 0.723942 0.384132 ## ..$ percent_a : num [1:108] 0.698 0.885 0.722 0.724 0.66 ...
## 5 National <NA> 2015 44 14687 97 68 1.12344 0.660448 0.462994 ## ..$ percent_b : num [1:108] 0.357 0.412 0.387 0.384 0.463 ...
## 6 National <NA> 2015 45 15048 122 86 1.38224 0.810739 0.571505 ## ..$ wk_date : Date[1:108], format: "2015-10-04" "2015-10-11" "2015-10-18" "2015-10-25" ...
## 7 National <NA> 2015 46 15250 84 98 1.19344 0.550820 0.642623
## 8 National <NA> 2015 47 15234 119 92 1.38506 0.781147 0.603912 ``` r
## 9 National <NA> 2015 48 16201 145 81 1.39498 0.895006 0.499969 mutate(xdat$combined_prior_to_2015_16,
## 10 National <NA> 2015 49 16673 140 106 1.47544 0.839681 0.635758 percent_positive = percent_positive / 100) %>%
## # ... with 98 more rows ggplot(aes(wk_date, percent_positive)) +
geom_line() +
scale_y_percent(name="% Positive") +
labs(x=NULL, title="WHO/NREVSS Surveillance Data (National)") +
theme_ipsum_rc(grid="XY")
```
![](README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-12-1.png)
``` r ``` r
who_nrevss("hhs") who_nrevss("hhs")
``` ```
## $combined_prior_to_2015_16 ## $combined_prior_to_2015_16
## # A tibble: 9,400 x 13 ## # A tibble: 9,400 x 14
## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3 a_subtyping_not_performed ## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3 a_subtyping_not_performed
## <chr> <chr> <int> <int> <int> <dbl> <int> <int> <int> <int> ## <chr> <chr> <int> <int> <int> <dbl> <int> <int> <int> <int>
## 1 HHS Regions Region 1 1997 40 51 0 0 0 0 0 ## 1 HHS Regions Region 1 1997 40 51 0 0 0 0 0
@ -577,38 +707,38 @@ who_nrevss("hhs")
## 8 HHS Regions Region 8 1997 40 78 0 0 0 0 0 ## 8 HHS Regions Region 8 1997 40 78 0 0 0 0 0
## 9 HHS Regions Region 9 1997 40 98 0 0 0 0 0 ## 9 HHS Regions Region 9 1997 40 98 0 0 0 0 0
## 10 HHS Regions Region 10 1997 40 48 0 0 0 0 0 ## 10 HHS Regions Region 10 1997 40 48 0 0 0 0 0
## # ... with 9,390 more rows, and 3 more variables: a_unable_to_subtype <int>, b <int>, h3n2v <int> ## # ... with 9,390 more rows, and 4 more variables: a_unable_to_subtype <int>, b <int>, h3n2v <int>, wk_date <date>
## ##
## $public_health_labs ## $public_health_labs
## # A tibble: 1,080 x 12 ## # A tibble: 1,080 x 13
## region_type region year week total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed b bvic byam ## region_type region year week total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed b bvic byam
## <chr> <chr> <int> <chr> <int> <int> <int> <int> <int> <int> <int> ## <chr> <chr> <int> <chr> <int> <int> <int> <int> <int> <int> <int>
## 1 HHS Regions Region 1 2015 XX 39 0 5 0 0 0 0 ## 1 HHS Regions Region 1 2015 <NA> 39 0 5 0 0 0 0
## 2 HHS Regions Region 2 2015 XX 56 1 4 0 1 0 0 ## 2 HHS Regions Region 2 2015 <NA> 56 1 4 0 1 0 0
## 3 HHS Regions Region 3 2015 XX 132 1 3 0 0 0 0 ## 3 HHS Regions Region 3 2015 <NA> 132 1 3 0 0 0 0
## 4 HHS Regions Region 4 2015 XX 83 0 5 0 1 0 0 ## 4 HHS Regions Region 4 2015 <NA> 83 0 5 0 1 0 0
## 5 HHS Regions Region 5 2015 XX 218 2 7 0 0 0 1 ## 5 HHS Regions Region 5 2015 <NA> 218 2 7 0 0 0 1
## 6 HHS Regions Region 6 2015 XX 97 0 2 0 0 0 0 ## 6 HHS Regions Region 6 2015 <NA> 97 0 2 0 0 0 0
## 7 HHS Regions Region 7 2015 XX 36 0 2 0 0 0 0 ## 7 HHS Regions Region 7 2015 <NA> 36 0 2 0 0 0 0
## 8 HHS Regions Region 8 2015 XX 71 0 2 0 0 0 0 ## 8 HHS Regions Region 8 2015 <NA> 71 0 2 0 0 0 0
## 9 HHS Regions Region 9 2015 XX 273 0 22 2 8 0 0 ## 9 HHS Regions Region 9 2015 <NA> 273 0 22 2 8 0 0
## 10 HHS Regions Region 10 2015 XX 134 0 13 0 0 0 0 ## 10 HHS Regions Region 10 2015 <NA> 134 0 13 0 0 0 0
## # ... with 1,070 more rows, and 1 more variables: h3n2v <int> ## # ... with 1,070 more rows, and 2 more variables: h3n2v <int>, wk_date <date>
## ##
## $clinical_labs ## $clinical_labs
## # A tibble: 1,080 x 10 ## # A tibble: 1,080 x 11
## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b ## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b wk_date
## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl> ## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl> <date>
## 1 HHS Regions Region 1 2015 40 693 2 3 0.721501 0.288600 0.432900 ## 1 HHS Regions Region 1 2015 40 693 2 3 0.721501 0.288600 0.432900 2015-10-04
## 2 HHS Regions Region 2 2015 40 1220 5 0 0.409836 0.409836 0.000000 ## 2 HHS Regions Region 2 2015 40 1220 5 0 0.409836 0.409836 0.000000 2015-10-04
## 3 HHS Regions Region 3 2015 40 896 0 1 0.111607 0.000000 0.111607 ## 3 HHS Regions Region 3 2015 40 896 0 1 0.111607 0.000000 0.111607 2015-10-04
## 4 HHS Regions Region 4 2015 40 2486 24 16 1.609010 0.965406 0.643604 ## 4 HHS Regions Region 4 2015 40 2486 24 16 1.609010 0.965406 0.643604 2015-10-04
## 5 HHS Regions Region 5 2015 40 2138 14 3 0.795136 0.654818 0.140318 ## 5 HHS Regions Region 5 2015 40 2138 14 3 0.795136 0.654818 0.140318 2015-10-04
## 6 HHS Regions Region 6 2015 40 1774 8 16 1.352870 0.450958 0.901917 ## 6 HHS Regions Region 6 2015 40 1774 8 16 1.352870 0.450958 0.901917 2015-10-04
## 7 HHS Regions Region 7 2015 40 621 2 1 0.483092 0.322061 0.161031 ## 7 HHS Regions Region 7 2015 40 621 2 1 0.483092 0.322061 0.161031 2015-10-04
## 8 HHS Regions Region 8 2015 40 824 1 1 0.242718 0.121359 0.121359 ## 8 HHS Regions Region 8 2015 40 824 1 1 0.242718 0.121359 0.121359 2015-10-04
## 9 HHS Regions Region 9 2015 40 980 25 2 2.755100 2.551020 0.204082 ## 9 HHS Regions Region 9 2015 40 980 25 2 2.755100 2.551020 0.204082 2015-10-04
## 10 HHS Regions Region 10 2015 40 397 3 0 0.755668 0.755668 0.000000 ## 10 HHS Regions Region 10 2015 40 397 3 0 0.755668 0.755668 0.000000 2015-10-04
## # ... with 1,070 more rows ## # ... with 1,070 more rows
``` r ``` r
@ -616,7 +746,7 @@ who_nrevss("census")
``` ```
## $combined_prior_to_2015_16 ## $combined_prior_to_2015_16
## # A tibble: 8,460 x 13 ## # A tibble: 8,460 x 14
## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3 ## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3
## <chr> <chr> <int> <int> <int> <dbl> <int> <int> <int> ## <chr> <chr> <int> <int> <int> <dbl> <int> <int> <int>
## 1 Census Regions New England 1997 40 51 0 0 0 0 ## 1 Census Regions New England 1997 40 51 0 0 0 0
@ -629,27 +759,27 @@ who_nrevss("census")
## 8 Census Regions Mountain 1997 40 85 0 0 0 0 ## 8 Census Regions Mountain 1997 40 85 0 0 0 0
## 9 Census Regions Pacific 1997 40 113 0 0 0 0 ## 9 Census Regions Pacific 1997 40 113 0 0 0 0
## 10 Census Regions New England 1997 41 54 0 0 0 0 ## 10 Census Regions New England 1997 41 54 0 0 0 0
## # ... with 8,450 more rows, and 4 more variables: a_subtyping_not_performed <int>, a_unable_to_subtype <int>, b <int>, ## # ... with 8,450 more rows, and 5 more variables: a_subtyping_not_performed <int>, a_unable_to_subtype <int>, b <int>,
## # h3n2v <int> ## # h3n2v <int>, wk_date <date>
## ##
## $public_health_labs ## $public_health_labs
## # A tibble: 972 x 12 ## # A tibble: 972 x 13
## region_type region year week total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed b ## region_type region year week total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed b
## <chr> <chr> <int> <chr> <int> <int> <int> <int> <int> ## <chr> <chr> <int> <chr> <int> <int> <int> <int> <int>
## 1 Census Regions New England 2015 XX 39 0 5 0 0 ## 1 Census Regions New England 2015 <NA> 39 0 5 0 0
## 2 Census Regions Mid-Atlantic 2015 XX 63 1 5 0 1 ## 2 Census Regions Mid-Atlantic 2015 <NA> 63 1 5 0 1
## 3 Census Regions East North Central 2015 XX 91 2 5 0 0 ## 3 Census Regions East North Central 2015 <NA> 91 2 5 0 0
## 4 Census Regions West North Central 2015 XX 169 0 4 0 0 ## 4 Census Regions West North Central 2015 <NA> 169 0 4 0 0
## 5 Census Regions South Atlantic 2015 XX 187 1 7 0 0 ## 5 Census Regions South Atlantic 2015 <NA> 187 1 7 0 0
## 6 Census Regions East South Central 2015 XX 21 0 0 0 1 ## 6 Census Regions East South Central 2015 <NA> 21 0 0 0 1
## 7 Census Regions West South Central 2015 XX 72 0 2 0 0 ## 7 Census Regions West South Central 2015 <NA> 72 0 2 0 0
## 8 Census Regions Mountain 2015 XX 111 0 6 0 0 ## 8 Census Regions Mountain 2015 <NA> 111 0 6 0 0
## 9 Census Regions Pacific 2015 XX 386 0 31 2 8 ## 9 Census Regions Pacific 2015 <NA> 386 0 31 2 8
## 10 Census Regions New England 2015 XX 39 2 3 0 0 ## 10 Census Regions New England 2015 <NA> 39 2 3 0 0
## # ... with 962 more rows, and 3 more variables: bvic <int>, byam <int>, h3n2v <int> ## # ... with 962 more rows, and 4 more variables: bvic <int>, byam <int>, h3n2v <int>, wk_date <date>
## ##
## $clinical_labs ## $clinical_labs
## # A tibble: 972 x 10 ## # A tibble: 972 x 11
## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b ## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b
## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl> ## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <dbl> <dbl>
## 1 Census Regions New England 2015 40 693 2 3 0.721501 0.288600 0.4329000 ## 1 Census Regions New England 2015 40 693 2 3 0.721501 0.288600 0.4329000
@ -662,14 +792,14 @@ who_nrevss("census")
## 8 Census Regions Mountain 2015 40 943 1 1 0.212089 0.106045 0.1060450 ## 8 Census Regions Mountain 2015 40 943 1 1 0.212089 0.106045 0.1060450
## 9 Census Regions Pacific 2015 40 1303 28 2 2.302380 2.148890 0.1534920 ## 9 Census Regions Pacific 2015 40 1303 28 2 2.302380 2.148890 0.1534920
## 10 Census Regions New England 2015 41 752 11 4 1.994680 1.462770 0.5319150 ## 10 Census Regions New England 2015 41 752 11 4 1.994680 1.462770 0.5319150
## # ... with 962 more rows ## # ... with 962 more rows, and 1 more variables: wk_date <date>
``` r ``` r
who_nrevss("state") who_nrevss("state")
``` ```
## $combined_prior_to_2015_16 ## $combined_prior_to_2015_16
## # A tibble: 14,094 x 13 ## # A tibble: 14,094 x 14
## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3 ## region_type region year week total_specimens percent_positive a_2009_h1n1 a_h1 a_h3
## <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> ## <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr>
## 1 States Alabama 2010 40 54 0 0 0 0 ## 1 States Alabama 2010 40 54 0 0 0 0
@ -682,11 +812,11 @@ who_nrevss("state")
## 8 States Delaware 2010 40 75 4 0 0 3 ## 8 States Delaware 2010 40 75 4 0 0 3
## 9 States District of Columbia 2010 40 14 0 0 0 0 ## 9 States District of Columbia 2010 40 14 0 0 0 0
## 10 States Florida 2010 40 <NA> <NA> <NA> <NA> <NA> ## 10 States Florida 2010 40 <NA> <NA> <NA> <NA> <NA>
## # ... with 14,084 more rows, and 4 more variables: a_subtyping_not_performed <chr>, a_unable_to_subtype <chr>, b <chr>, ## # ... with 14,084 more rows, and 5 more variables: a_subtyping_not_performed <chr>, a_unable_to_subtype <chr>, b <chr>,
## # h3n2v <chr> ## # h3n2v <chr>, wk_date <date>
## ##
## $public_health_labs ## $public_health_labs
## # A tibble: 162 x 11 ## # A tibble: 162 x 12
## region_type region season_description total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed ## region_type region season_description total_specimens a_2009_h1n1 a_h3 a_subtyping_not_performed
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> ## <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 States Alabama Season 2015-16 256 59 16 1 ## 1 States Alabama Season 2015-16 256 59 16 1
@ -699,10 +829,10 @@ who_nrevss("state")
## 8 States Delaware Season 2015-16 2754 414 20 12 ## 8 States Delaware Season 2015-16 2754 414 20 12
## 9 States District of Columbia Season 2015-16 172 68 3 0 ## 9 States District of Columbia Season 2015-16 172 68 3 0
## 10 States Florida Season 2015-16 <NA> <NA> <NA> <NA> ## 10 States Florida Season 2015-16 <NA> <NA> <NA> <NA>
## # ... with 152 more rows, and 4 more variables: b <chr>, bvic <chr>, byam <chr>, h3n2v <chr> ## # ... with 152 more rows, and 5 more variables: b <chr>, bvic <chr>, byam <chr>, h3n2v <chr>, wk_date <date>
## ##
## $clinical_labs ## $clinical_labs
## # A tibble: 5,832 x 10 ## # A tibble: 5,832 x 11
## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b ## region_type region year week total_specimens total_a total_b percent_positive percent_a percent_b
## <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> <chr> ## <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 States Alabama 2015 40 167 2 3 2.99 1.2 1.8 ## 1 States Alabama 2015 40 167 2 3 2.99 1.2 1.8
@ -715,7 +845,7 @@ who_nrevss("state")
## 8 States Delaware 2015 40 22 0 0 0 0 0 ## 8 States Delaware 2015 40 22 0 0 0 0 0
## 9 States District of Columbia 2015 40 <NA> <NA> <NA> <NA> <NA> <NA> ## 9 States District of Columbia 2015 40 <NA> <NA> <NA> <NA> <NA> <NA>
## 10 States Florida 2015 40 <NA> <NA> <NA> <NA> <NA> <NA> ## 10 States Florida 2015 40 <NA> <NA> <NA> <NA> <NA> <NA>
## # ... with 5,822 more rows ## # ... with 5,822 more rows, and 1 more variables: wk_date <date>
Code of Conduct Code of Conduct
--------------- ---------------

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-10-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-12-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 65 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-5-6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-7-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-8-4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

BIN
README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-9-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

21
man/mmwr_week.Rd

@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mmwr-map.r
\name{mmwr_week}
\alias{mmwr_week}
\title{Convert a Date to an MMWR day+week+year}
\usage{
mmwr_week(x)
}
\arguments{
\item{x}{a vector of \code{Date} objects or a character vector in \code{YYYY-mm-dd} format.}
}
\value{
data frame (tibble)
}
\description{
This is a reformat and re-export of a function in the \code{MMWRweek} package.
It provides a snake case version of its counterpart, produces a \code{tibble}
}
\examples{
mmwr_week(Sys.Date())
}

24
man/mmwr_week_to_date.Rd

@ -0,0 +1,24 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mmwr-map.r
\name{mmwr_week_to_date}
\alias{mmwr_week_to_date}
\title{Convert an MMWR year+week or year+week+day to a Date object}
\usage{
mmwr_week_to_date(year, week, day = NULL)
}
\arguments{
\item{year, week, day}{Year, week and month vectors. All must be the same length
unless \code{day} is \code{NULL}.}
}
\value{
vector of \code{Date} objects
}
\description{
This is a reformat and re-export of a function in the \code{MMWRweek} package.
It provides a snake case version of its counterpart and produces a vector
of \code{Date} objects that corresponds to the input MMWR year+week or year+week+day
vectors. This also adds some parameter checking and cleanup to avoid exceptions.
}
\examples{
mmwr_week_to_date(2016,10,3)
}

29
man/mmwr_weekday.Rd

@ -0,0 +1,29 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mmwr-map.r
\name{mmwr_weekday}
\alias{mmwr_weekday}
\title{Convert a Date to an MMWR weekday}
\usage{
mmwr_weekday(x, abbr = FALSE)
}
\arguments{
\item{x}{a vector of \code{Date} objects or a character vector in \code{YYYY-mm-dd} format.}
\item{abbr}{(logical) if \code{TRUE}, return abbreviated weekday names, otherwise full
weekday names (see Note).}
}
\value{
ordered factor
}
\description{
This is a reformat and re-export of a function in the \code{MMWRweek} package.
It provides a snake case version of its counterpart, produces a \code{factor} of
weekday names (Sunday-Saturday).
}
\note{
Weekday names are explicitly mapped to "Sunday-Saturday" or "Sun-Sat" and
do not change with your locale.
}
\examples{
mmwr_weekday(Sys.Date())
}

15
man/mmwrid_map.Rd

@ -1,5 +1,20 @@
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mmwr-map.r % Please edit documentation in R/mmwr-map.r
\docType{data}
\name{mmwrid_map} \name{mmwrid_map}
\alias{mmwrid_map} \alias{mmwrid_map}
\title{MMWR ID to Calendar Mappings} \title{MMWR ID to Calendar Mappings}
\format{A data frame with 4,592 rows and 4 columns}
\description{
The CDC uses a unique "Morbidity and Mortality Weekly Report" identifier
for each week that starts at 1 (Ref: < https://www.cdc.gov/mmwr/preview/mmwrhtml/su6004a9.htm>).
This data frame consists of 4 columns:
\itemize{
\item \code{wk_start}: Start date (Sunday) for the week (\code{Date})
\item \code{wk_end}: End date (Saturday) for the week (\code{Date})
\item \code{year_wk_num}: The week of the calendar year
\item \code{mmwrid}: The unique MMWR identifier
These can be "left-joined" to data provided from the CDC to perform MMWR identifier
to date mappings.
}
}

15
tests/testthat/test-cdcfluview.R

@ -3,7 +3,7 @@ test_that("we can do something", {
skip_on_cran() skip_on_cran()
expect_that(agd_ipt(), is_a("data.frame")) expect_that(age_group_distribution(), is_a("data.frame"))
expect_that(geographic_spread(), is_a("data.frame")) expect_that(geographic_spread(), is_a("data.frame"))
@ -40,5 +40,18 @@ test_that("we can do something", {
expect_that(cdc_basemap("spread"), is_a("sf")) expect_that(cdc_basemap("spread"), is_a("sf"))
expect_that(cdc_basemap("surv"), is_a("sf")) expect_that(cdc_basemap("surv"), is_a("sf"))
expect_equal(mmwr_week(Sys.Date()),
structure(list(mmwr_year = 2017, mmwr_week = 45, mmwr_day = 2),
.Names = c("mmwr_year", "mmwr_week", "mmwr_day"),
row.names = c(NA, -1L),
class = c("tbl_df", "tbl", "data.frame"))
)
expect_equal(mmwr_weekday(Sys.Date()),
structure(2L, .Label = c("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"),
class = "factor"))
expect_equal(mmwr_week_to_date(2016,10,3), structure(16868, class = "Date"))
}) })

Loading…
Cancel
Save