Bob Rudis
8 years ago
22 changed files with 271 additions and 159 deletions
@ -1,10 +1,17 @@ |
|||
# Generated by roxygen2 (4.1.1): do not edit by hand |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
export(get_flu_data) |
|||
export(get_mortality_surveillance_data) |
|||
export(get_state_data) |
|||
export(get_weekly_flu_report) |
|||
import(dplyr) |
|||
import(httr) |
|||
import(pbapply) |
|||
import(utils) |
|||
import(xml2) |
|||
importFrom(purrr,discard) |
|||
importFrom(purrr,keep) |
|||
importFrom(purrr,map) |
|||
importFrom(purrr,map_chr) |
|||
importFrom(purrr,map_df) |
|||
importFrom(purrr,map_lgl) |
|||
importFrom(readr,read_csv) |
|||
|
@ -0,0 +1,8 @@ |
|||
# cdcfluview 0.5.0 |
|||
|
|||
* Fixed issue with WHO data format change |
|||
* Added Mortality Surveillance Data retrieval function |
|||
* Switched to readr::read_csv() and since it handles column names |
|||
better this will break your scripts until you use the new |
|||
column names. |
|||
|
@ -0,0 +1,78 @@ |
|||
#' Mortality Surveillance Data from the National Center for Health Statistics |
|||
#' |
|||
#' The National Center for Health Statistics (NCHS) collects and disseminates the Nation's |
|||
#' official vital statistics. These statistics are based on data provided to NCHS through |
|||
#' contracts with the vital registration systems operated in the various jurisdictions |
|||
#' legally responsible for the registration of deaths (i.e., death certificates) and other |
|||
#' vital events. These data have previously only been released as annual final data files |
|||
#' 12 months or more after the end of the data year. Recent NCHS efforts to improve the |
|||
#' timeliness of jurisdiction reporting and modernize the national vital statistics |
|||
#' infrastructure have created a system capable of supporting near real-time surveillance. |
|||
#' Capitalizing on these new capabilities, NCHS and CDC’s Influenza Division have |
|||
#' partnered to pilot the use of NCHS mortality surveillance data for Pneumonia and |
|||
#' Influenza (P&I) mortality surveillance. |
|||
#' |
|||
#' NCHS mortality surveillance data are presented by the week the death occurred. |
|||
#' Nationally P&I percentages are released two weeks after the week of death to allow for |
|||
#' collection of enough data to produce a stable P&I percentage at the national level. |
|||
#' Collection of complete data is not expected, and reliable P&I ratios are not expected |
|||
#' at the region and state level within this two week period. State and Region level |
|||
#' counts will be released only after 20% of the expected number of deaths are reported |
|||
#' through the system. |
|||
#' |
|||
#' @references \url{http://www.cdc.gov/flu/weekly/nchs.htm} |
|||
#' @return a list of \code{tbl_df}s |
|||
#' @export |
|||
#' @examples \dontrun{ |
|||
#' get_mortality_surveillance_data() |
|||
#' } |
|||
get_mortality_surveillance_data <- function() { |
|||
|
|||
pg <- read_html("http://www.cdc.gov/flu/weekly/nchs.htm") |
|||
|
|||
PREFIX <- "http://www.cdc.gov" |
|||
|
|||
xml_find_all(pg, ".//select[@id='State']/option[contains(@value, 'csv') and |
|||
contains(@value, 'State_')]") %>% |
|||
xml_attr("value") %>% |
|||
sprintf("%s%s", PREFIX, .) -> targets |
|||
|
|||
pb <- progress_estimated(length(targets)) |
|||
map_df(targets, function(x) { |
|||
pb$tick()$print() |
|||
suppressMessages(read_csv(URLencode(x), col_types="ciidii")) |
|||
}) -> influenza_mortality_by_state |
|||
|
|||
|
|||
xml_find_all(pg, ".//select[@id='Regional Data']/ |
|||
option[contains(@value, 'csv') and |
|||
not(contains(@value, 'Week_'))]") %>% |
|||
xml_attr("value") %>% |
|||
sprintf("%s%s", PREFIX, .) -> targets |
|||
|
|||
pb <- progress_estimated(length(targets)) |
|||
map_df(targets, function(x) { |
|||
pb$tick()$print() |
|||
suppressMessages(read_csv(URLencode(x), col_types="ciidii")) |
|||
}) -> influenza_mortality_by_region |
|||
|
|||
|
|||
xml_find_all(pg, ".//select[@id='Regional Data']/ |
|||
option[contains(@value, 'csv') and |
|||
contains(@value, 'Week_')]") %>% |
|||
xml_attr("value") %>% |
|||
sprintf("%s%s", PREFIX, .) -> targets |
|||
|
|||
pb <- progress_estimated(length(targets)) |
|||
map_df(targets, function(x) { |
|||
pb$tick()$print() |
|||
suppressMessages(read_csv(URLencode(x), col_types="ciidii")) |
|||
}) -> influenza_mortality_by_week |
|||
|
|||
list( |
|||
by_state=influenza_mortality_by_state, |
|||
by_region=influenza_mortality_by_region, |
|||
by_week=influenza_mortality_by_week |
|||
) |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
.onAttach <- function(...) { |
|||
|
|||
if (!interactive()) return() |
|||
|
|||
packageStartupMessage(paste0("cdcfluview is under *active* development. ", |
|||
"There are *breaking changes*. ", |
|||
"See https://github.com/hrbrmstr/cdcfluview for info/news.")) |
|||
|
|||
} |
|||
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 343 KiB After Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
@ -0,0 +1,42 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/mortalty.r |
|||
\name{get_mortality_surveillance_data} |
|||
\alias{get_mortality_surveillance_data} |
|||
\title{Mortality Surveillance Data from the National Center for Health Statistics} |
|||
\usage{ |
|||
get_mortality_surveillance_data() |
|||
} |
|||
\value{ |
|||
a list of \code{tbl_df}s |
|||
} |
|||
\description{ |
|||
The National Center for Health Statistics (NCHS) collects and disseminates the Nation's |
|||
official vital statistics. These statistics are based on data provided to NCHS through |
|||
contracts with the vital registration systems operated in the various jurisdictions |
|||
legally responsible for the registration of deaths (i.e., death certificates) and other |
|||
vital events. These data have previously only been released as annual final data files |
|||
12 months or more after the end of the data year. Recent NCHS efforts to improve the |
|||
timeliness of jurisdiction reporting and modernize the national vital statistics |
|||
infrastructure have created a system capable of supporting near real-time surveillance. |
|||
Capitalizing on these new capabilities, NCHS and CDC’s Influenza Division have |
|||
partnered to pilot the use of NCHS mortality surveillance data for Pneumonia and |
|||
Influenza (P&I) mortality surveillance. |
|||
} |
|||
\details{ |
|||
NCHS mortality surveillance data are presented by the week the death occurred. |
|||
Nationally P&I percentages are released two weeks after the week of death to allow for |
|||
collection of enough data to produce a stable P&I percentage at the national level. |
|||
Collection of complete data is not expected, and reliable P&I ratios are not expected |
|||
at the region and state level within this two week period. State and Region level |
|||
counts will be released only after 20% of the expected number of deaths are reported |
|||
through the system. |
|||
} |
|||
\examples{ |
|||
\dontrun{ |
|||
get_mortality_surveillance_data() |
|||
} |
|||
} |
|||
\references{ |
|||
\url{http://www.cdc.gov/flu/weekly/nchs.htm} |
|||
} |
|||
|
Loading…
Reference in new issue