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

166 lines
5.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. ---
  2. title: ""
  3. pagetitle: ""
  4. output: rmarkdown::github_document
  5. ---
  6. [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/cdcfluview)](https://cran.r-project.org/package=cdcfluview)
  7. [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/cdcfluview.svg?branch=master)](https://travis-ci.org/hrbrmstr/cdcfluview)
  8. [![Coverage Status](https://img.shields.io/codecov/c/github/hrbrmstr/cdcfluview/master.svg)](https://codecov.io/github/hrbrmstr/cdcfluview?branch=master)
  9. # I M P O R T A N T
  10. The CDC migrated to a new non-Flash portal and back-end APIs changed. This is a complete reimagining of the package and --- as such --- all your code is going to break. Please use GitHub issues to identify previous API functionality you would like ported over. There's a [release candidate for 0.5.2](https://github.com/hrbrmstr/cdcfluview/releases/tag/v0.5.2) which uses the old API but it likely to break in the near future given the changes to the hidden API. You can do what with `devtools::install_github("hrbrmstr/cdcfluview", ref="58c172b")`.
  11. All folks providing feedback, code or suggestions will be added to the DESCRIPTION file. Please include how you would prefer to be cited in any issues you file.
  12. If there's a particular data set from https://www.cdc.gov/flu/weekly/fluviewinteractive.htm that you want and that isn't in the package, please file it as an issue and be as specific as you can (screen shot if possible).
  13. # :mask: cdcfluview
  14. Retrieve U.S. Flu Season Data from the CDC FluView Portal
  15. ## Description
  16. The U.S. Centers for Disease Control (CDC) maintains a portal <http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html> for accessing state, regional and national influenza statistics as well as Mortality Surveillance Data. The Flash interface makes it difficult and time-consuming to select and retrieve influenza data. This package provides functions to access the data provided by the portal's underlying API.
  17. ## What's Inside The Tin
  18. The following functions are implemented:
  19. - `age_group_distribution`: Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
  20. - `cdc_basemap`: Retrieve CDC U.S. Basemaps
  21. - `geographic_spread`: State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
  22. - `hospitalizations`: Laboratory-Confirmed Influenza Hospitalizations
  23. - `ilinet`: Retrieve ILINet Surveillance Data
  24. - `ili_weekly_activity_indicators`: Retrieve weekly state-level ILI indicators per-state for a given season
  25. - `pi_mortality`: Pneumonia and Influenza Mortality Surveillance
  26. - `state_data_providers`: Retrieve metadata about U.S. State CDC Provider Data
  27. - `surveillance_areas`: Retrieve a list of valid sub-regions for each surveillance area.
  28. - `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data
  29. The following data sets are included:
  30. - `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables)
  31. - `census_regions` Census Region Table (a data frame with 51 rows and 2 variables)
  32. ## Installation
  33. ```{r eval=FALSE}
  34. devtools::install_github("hrbrmstr/cdcfluview")
  35. ```
  36. ```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
  37. options(width=120)
  38. ```
  39. ## Usage
  40. ```{r message=FALSE, warning=FALSE, error=FALSE}
  41. library(cdcfluview)
  42. library(hrbrthemes)
  43. library(tidyverse)
  44. # current verison
  45. packageVersion("cdcfluview")
  46. ```
  47. ### Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
  48. ```{r message=FALSE, warning=FALSE}
  49. glimpse(age_group_distribution())
  50. ```
  51. ### Retrieve CDC U.S. Coverage Map
  52. ```{r message=FALSE, warning=FALSE}
  53. plot(cdc_basemap("national"))
  54. plot(cdc_basemap("hhs"))
  55. plot(cdc_basemap("census"))
  56. plot(cdc_basemap("states"))
  57. plot(cdc_basemap("spread"))
  58. plot(cdc_basemap("surv"))
  59. ```
  60. ### State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
  61. ```{r message=FALSE, warning=FALSE}
  62. glimpse(geographic_spread())
  63. ```
  64. ### Laboratory-Confirmed Influenza Hospitalizations
  65. ```{r message=FALSE, warning=FALSE}
  66. surveillance_areas()
  67. glimpse(hospitalizations("flusurv"))
  68. glimpse(hospitalizations("eip"))
  69. glimpse(hospitalizations("eip", "Colorado"))
  70. glimpse(hospitalizations("ihsp"))
  71. glimpse(hospitalizations("ihsp", "Oklahoma"))
  72. ```
  73. ### Retrieve ILINet Surveillance Data
  74. ```{r message=FALSE, warning=FALSE}
  75. walk(c("national", "hhs", "census", "state"), ~{
  76. ili_df <- ilinet(region = .x)
  77. print(glimpse(ili_df))
  78. ggplot(ili_df, aes(week_start, unweighted_ili, group=region, color=region)) +
  79. geom_line() +
  80. viridis::scale_color_viridis(discrete=TRUE) +
  81. labs(x=NULL, y="Unweighted ILI", title=ili_df$region_type[1]) +
  82. theme_ipsum_rc(grid="XY") +
  83. theme(legend.position = "none") -> gg
  84. print(gg)
  85. })
  86. ```
  87. ### Retrieve weekly state-level ILI indicators per-state for a given season
  88. ```{r message=FALSE, warning=FALSE}
  89. ili_weekly_activity_indicators(2017)
  90. ili_weekly_activity_indicators(2015)
  91. ```
  92. ### Pneumonia and Influenza Mortality Surveillance
  93. ```{r message=FALSE, warning=FALSE}
  94. pi_mortality("national")
  95. pi_mortality("state")
  96. pi_mortality("region")
  97. ```
  98. ### Retrieve metadata about U.S. State CDC Provider Data
  99. ```{r message=FALSE, warning=FALSE}
  100. state_data_providers()
  101. ```
  102. ### Retrieve WHO/NREVSS Surveillance Data
  103. ```{r message=FALSE, warning=FALSE}
  104. who_nrevss("national")
  105. who_nrevss("hhs")
  106. who_nrevss("census")
  107. who_nrevss("state")
  108. ```
  109. ## Code of Conduct
  110. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.