boB Rudis
7 years ago
18 changed files with 220 additions and 113 deletions
@ -1,28 +1,40 @@ |
|||
#' Retrieve CDC U.S. Coverage Map |
|||
#' Retrieve CDC U.S. Basemaps |
|||
#' |
|||
#' The CDC FluView application uses a composite basemap of coverage areas |
|||
#' within the United States that elides and scales Alaska, Hawaii and |
|||
#' Puerto Rico and provides elided and scaled breakouts for New York City |
|||
#' and the District of Columbia.\cr |
|||
#' The CDC FluView application uses a composite basemaps of coverage areas |
|||
#' within the United States that elides and scales Alaska, Hawaii, |
|||
#' Puerto Rico & the Virgin Islands and some further provide elided and scaled |
|||
#' breakouts for New York City and the District of Columbia.\cr |
|||
#' \cr |
|||
#' The basemap provides polygon identifiers by: |
|||
#' \cr |
|||
#' - `STATE_FIPS` |
|||
#' - `STATE_ABBR` |
|||
#' - `STATE_NAME` |
|||
#' - `HHS_Region` |
|||
#' - `FIPSTXT`) |
|||
#' \cr |
|||
#' This function retrieves the shapefile, projects to EPSG:5069 and |
|||
#' This function retrieves the given shapefile, projects to EPSG:5069 and |
|||
#' returns it as an `sf` (simple features) object. |
|||
#' |
|||
#' @md |
|||
#' @export |
|||
#' @param basemap select the CDC basemap. One of: |
|||
#' - "`national`": outline of the U.S. + AK, HI, PR + VI |
|||
#' - "`hhs`": outline of the U.S. + HHS Region Outlines + AK, HI, PR + VI |
|||
#' - "`census`": outline of the U.S. + Census Region Outlines + AK, HI, PR + VI |
|||
#' - "`states`": outline of the U.S. + State Outlines + AK, HI, PR + VI |
|||
#' - "`spread`": outline of the U.S. + State Outlines + AK, HI, PR + VI & Guam |
|||
#' - "`surv`": outline of the U.S. + State Outlines + AK, HI, PR + VI |
|||
#' @note These are just the basemaps. You need to pair it with the data you wish to visualize. |
|||
#' @examples \dontrun{ |
|||
#' plot(cdc_coverage_map()) |
|||
#' plot(cdc_basemap("national")) |
|||
#' } |
|||
cdc_coverage_map <- function() { |
|||
xsf <- sf::st_read(.cdc_basemap, quiet=TRUE, stringsAsFactors=FALSE) |
|||
cdc_basemap <- function(basemap = c("national", "hhs", "census", "states", "spread", "surv")) { |
|||
|
|||
switch( |
|||
basemap, |
|||
national = .national_outline, |
|||
hhs = .hhs_subregions_basemap, |
|||
census = .census_divisions_basemap, |
|||
states = .states_basemap, |
|||
spread = .spread_basemap, |
|||
surv = .surv_basemap |
|||
) -> selected_map |
|||
|
|||
xsf <- sf::st_read(selected_map, quiet=TRUE, stringsAsFactors=FALSE) |
|||
sf::st_crs(xsf) <- 4326 |
|||
sf::st_transform(xsf, 5069) |
|||
|
|||
} |
|||
|
@ -1,10 +1,10 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/agd-ipt.r |
|||
\name{agd_ipt} |
|||
\alias{agd_ipt} |
|||
\name{age_group_distribution} |
|||
\alias{age_group_distribution} |
|||
\title{Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories} |
|||
\usage{ |
|||
agd_ipt() |
|||
age_group_distribution() |
|||
} |
|||
\description{ |
|||
Retrieves the age group distribution of influenza positive tests that are reported by |
@ -0,0 +1,37 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/coverage-map.r |
|||
\name{cdc_basemap} |
|||
\alias{cdc_basemap} |
|||
\title{Retrieve CDC U.S. Basemaps} |
|||
\usage{ |
|||
cdc_basemap(basemap = c("national", "hhs", "census", "states", "spread", |
|||
"surv")) |
|||
} |
|||
\arguments{ |
|||
\item{basemap}{select the CDC basemap. One of: |
|||
\itemize{ |
|||
\item "\code{national}": outline of the U.S. + AK, HI, PR + VI |
|||
\item "\code{hhs}": outline of the U.S. + HHS Region Outlines + AK, HI, PR + VI |
|||
\item "\code{census}": outline of the U.S. + Census Region Outlines + AK, HI, PR + VI |
|||
\item "\code{states}": outline of the U.S. + State Outlines + AK, HI, PR + VI |
|||
\item "\code{spread}": outline of the U.S. + State Outlines + AK, HI, PR + VI & Guam |
|||
\item "\code{surv}": outline of the U.S. + State Outlines + AK, HI, PR + VI |
|||
}} |
|||
} |
|||
\description{ |
|||
The CDC FluView application uses a composite basemaps of coverage areas |
|||
within the United States that elides and scales Alaska, Hawaii, |
|||
Puerto Rico & the Virgin Islands and some further provide elided and scaled |
|||
breakouts for New York City and the District of Columbia.\cr |
|||
\cr |
|||
This function retrieves the given shapefile, projects to EPSG:5069 and |
|||
returns it as an \code{sf} (simple features) object. |
|||
} |
|||
\note{ |
|||
These are just the basemaps. You need to pair it with the data you wish to visualize. |
|||
} |
|||
\examples{ |
|||
\dontrun{ |
|||
plot(cdc_basemap("national")) |
|||
} |
|||
} |
@ -1,32 +0,0 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/coverage-map.r |
|||
\name{cdc_coverage_map} |
|||
\alias{cdc_coverage_map} |
|||
\title{Retrieve CDC U.S. Coverage Map} |
|||
\usage{ |
|||
cdc_coverage_map() |
|||
} |
|||
\description{ |
|||
The CDC FluView application uses a composite basemap of coverage areas |
|||
within the United States that elides and scales Alaska, Hawaii and |
|||
Puerto Rico and provides elided and scaled breakouts for New York City |
|||
and the District of Columbia.\cr |
|||
\cr |
|||
The basemap provides polygon identifiers by: |
|||
\cr |
|||
\itemize{ |
|||
\item \code{STATE_FIPS} |
|||
\item \code{STATE_ABBR} |
|||
\item \code{STATE_NAME} |
|||
\item \code{HHS_Region} |
|||
\item \code{FIPSTXT}) |
|||
\cr |
|||
This function retrieves the shapefile, projects to EPSG:5069 and |
|||
returns it as an \code{sf} (simple features) object. |
|||
} |
|||
} |
|||
\examples{ |
|||
\dontrun{ |
|||
plot(cdc_coverage_map()) |
|||
} |
|||
} |
@ -1,26 +1,44 @@ |
|||
context("basic functionality") |
|||
test_that("we can do something", { |
|||
|
|||
skip_on_cran() |
|||
|
|||
expect_that(agd_ipt(), is_a("data.frame")) |
|||
|
|||
expect_that(geographic_spread(), is_a("data.frame")) |
|||
expect_that(surveillance_areas(), is_a("data.frame")) |
|||
|
|||
expect_that(state_data_providers(), is_a("data.frame")) |
|||
|
|||
expect_that(hospitalizations("flusurv"), is_a("data.frame")) |
|||
expect_that(hospitalizations("eip"), is_a("data.frame")) |
|||
expect_that(hospitalizations("eip", "Colorado"), is_a("data.frame")) |
|||
expect_that(hospitalizations("ihsp"), is_a("data.frame")) |
|||
expect_that(hospitalizations("ihsp", "Oklahoma"), is_a("data.frame")) |
|||
|
|||
expect_that(ilinet("national"), is_a("data.frame")) |
|||
expect_that(ilinet("hhs"), is_a("data.frame")) |
|||
expect_that(ilinet("census"), is_a("data.frame")) |
|||
expect_that(ilinet("state"), is_a("data.frame")) |
|||
|
|||
expect_that(ili_weekly_activity_indicators(2017), is_a("data.frame")) |
|||
|
|||
expect_that(pi_mortality("national"), is_a("data.frame")) |
|||
expect_that(pi_mortality("state"), is_a("data.frame")) |
|||
expect_that(pi_mortality("region"), is_a("data.frame")) |
|||
expect_that(state_data_providers(), is_a("data.frame")) |
|||
|
|||
expect_that(surveillance_areas(), is_a("data.frame")) |
|||
|
|||
expect_that(who_nrevss("national"), is_a("list")) |
|||
expect_that(who_nrevss("hhs"), is_a("list")) |
|||
expect_that(who_nrevss("census"), is_a("list")) |
|||
expect_that(who_nrevss("state"), is_a("list")) |
|||
expect_that(cdc_coverage_map(), is_a("sf")) |
|||
|
|||
expect_that(cdc_basemap("national"), is_a("sf")) |
|||
expect_that(cdc_basemap("hhs"), is_a("sf")) |
|||
expect_that(cdc_basemap("census"), is_a("sf")) |
|||
expect_that(cdc_basemap("states"), is_a("sf")) |
|||
expect_that(cdc_basemap("spread"), is_a("sf")) |
|||
expect_that(cdc_basemap("surv"), is_a("sf")) |
|||
|
|||
|
|||
}) |
|||
|
Loading…
Reference in new issue