Browse Source

updated examples and travis config

pull/20/head
boB Rudis 2 years ago
parent
commit
86a027629f
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
26 changed files with 95 additions and 88 deletions
  1. +54
    -30
      .travis.yml
  2. +1
    -1
      R/agd-ipt.r
  3. +2
    -2
      R/geographic-spread.R
  4. +0
    -3
      R/get-flu-data.r
  5. +1
    -1
      R/get-hosp-data.r
  6. +4
    -5
      R/get-state-data.r
  7. +4
    -2
      R/get-weekly-flu-report.r
  8. +5
    -4
      R/hospital.r
  9. +2
    -2
      R/ili-weekly-state.r
  10. +2
    -5
      R/ilinet.r
  11. +3
    -3
      R/mmwr-map.r
  12. +2
    -2
      R/pi-mortality.r
  13. +0
    -4
      R/zzz.r
  14. +1
    -1
      man/age_group_distribution.Rd
  15. +1
    -1
      man/geographic_spread.Rd
  16. +0
    -5
      man/get_flu_data.Rd
  17. +1
    -1
      man/get_hosp_data.Rd
  18. +3
    -4
      man/get_state_data.Rd
  19. +1
    -1
      man/get_weekly_flu_report.Rd
  20. +1
    -1
      man/ili_weekly_activity_indicators.Rd
  21. +2
    -5
      man/ilinet.Rd
  22. +1
    -1
      man/mmwr_week.Rd
  23. +1
    -1
      man/mmwr_week_to_date.Rd
  24. +1
    -1
      man/mmwr_weekday.Rd
  25. +1
    -1
      man/state_data_providers.Rd
  26. +1
    -1
      man/surveillance_areas.Rd

+ 54
- 30
.travis.yml View File

@ -1,30 +1,54 @@
language: r
r:
- release
- devel
sudo: required
dist: trusty
cache: packages
cache:
- packages
- ccache
dist: trusty
latex: false
r_github_packages:
- r-dbi/DBI
- r-dbi/RPostgres
- r-lib/covr
- r-spatial/lwgeom
- r-spatial/stars
addons:
postgresql: "9.6"
apt:
sources:
- sourceline: 'ppa:opencpu/jq'
- sourceline: 'ppa:ubuntugis/ubuntugis-unstable'
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages:
- libprotobuf-dev
- protobuf-compiler
- libv8-3.14-dev
- libjq-dev
- libudunits2-dev
- libproj-dev
- libgeos-dev
- libspatialite-dev
- libgdal-dev
- libjson-c-dev
- libnetcdf-dev
- netcdf-bin
- postgresql-server-dev-9.6
before_install:
- sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
- sudo apt-get --yes --force-yes update -qq
# install tmap dependencies
- sudo apt-get install --yes libprotobuf-dev protobuf-compiler libv8-3.14-dev
# install tmap dependencies; for 16.04 libjq-dev this ppa is needed:
- sudo add-apt-repository -y ppa:opencpu/jq
- sudo apt-get --yes --force-yes update -qq
- sudo apt-get install libjq-dev
# units/udunits2 dependency:
- sudo apt-get install --yes libudunits2-dev
# sf dependencies:
- sudo apt-get install --yes libproj-dev libgeos-dev libgdal-dev
# postgis source compile dependencies:
- sudo apt-get --yes install libjson-c-dev postgresql-server-dev-9.6
# install postgis from source:
- wget http://download.osgeo.org/postgis/source/postgis-2.3.2.tar.gz
- (mv postgis* /tmp; cd /tmp; tar xzf postgis-2.3.2.tar.gz)
- (cd /tmp/postgis-2.3.2 ; ./configure; make; sudo make install)
# install postgis from source, to avoid dependency conflict with GDAL >= 2.0:
- wget http://download.osgeo.org/postgis/source/postgis-2.4.3.tar.gz
- (mv postgis* /tmp; cd /tmp; tar xzf postgis-2.4.3.tar.gz)
- (cd /tmp/postgis-2.4.3 ; ./configure; make; sudo make install)
# activate liblwgeom by:
- sudo ldconfig
# create postgis databases:
@ -32,21 +56,21 @@ before_install:
- createdb postgis
- psql -d postgis -c "CREATE EXTENSION postgis;"
- psql -d postgis -c "GRANT CREATE ON DATABASE postgis TO travis"
- psql -d postgis -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO travis"
- createdb empty
- psql -d empty -c "CREATE EXTENSION postgis;"
addons:
postgresql: "9.6"
r:
- oldrel
- release
- devel
- R -q -e 'install.packages("remotes"); remotes::install_github("ropenscilabs/tic"); tic::prepare_all_stages()'
after_success:
- dropdb postgis
- dropdb empty
- createdb postgis
- psql -d postgis -c "CREATE EXTENSION postgis;"
- psql -d postgis -c "GRANT CREATE ON DATABASE postgis TO travis"
- Rscript -e 'covr::codecov()'
- psql -d postgis -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO travis"
- createdb empty
- psql -d empty -c "CREATE EXTENSION postgis;"
- R -q -e 'covr::codecov(quiet = FALSE)'
install: R -q -e 'tic::install()'
script: R -q -e 'tic::script()'

+ 1
- 1
R/agd-ipt.r View File

@ -16,7 +16,7 @@
#' to a year.
#' @export
#' @examples
#' age_group_distribution(years=2015)
#' agd <- age_group_distribution(years=2015)
age_group_distribution <- function(years = NULL) {
httr::GET(


+ 2
- 2
R/geographic-spread.R View File

@ -10,7 +10,7 @@
#' to a year.
#' @export
#' @examples \dontrun{
#' geographic_spread()
#' gs <- geographic_spread()
#' }
geographic_spread <- function(years=NULL) {
@ -57,7 +57,7 @@ geographic_spread <- function(years=NULL) {
res <- httr::content(res, as="parsed", flatten=TRUE)
xdf <- dplyr::bind_rows(res$datadownload)
suppressMessages(suppressWarnings(xdf <- dplyr::bind_rows(res$datadownload)))
xdf$weekend <- as.Date(xdf$weekend, format="%B-%d-%Y")
xdf


+ 0
- 3
R/get-flu-data.r View File

@ -30,9 +30,6 @@
#' servers to crunch the data. Wrap the function call in \code{httr::with_verbose}
#' if you would like to see what's going on.
#' @export
#' @examples \dontrun{
#' flu <- get_flu_data("hhs", 1:10, c("who", "ilinet"), years=2000:2014)
#' }
get_flu_data <- function(region="hhs", sub_region=1:10,
data_source="ilinet",
years=as.numeric(format(Sys.Date(), "%Y"))) {


+ 1
- 1
R/get-hosp-data.r View File

@ -22,7 +22,7 @@
#' @export
#' @examples \dontrun{
#' # All of FluSurv-NET, 50-64 years old, 2010/11-2014/15 flu seasons
#' flu <- get_hosp_data("flusurvnet", "50-64y", years=2010:2014)
#' hosp <- get_hosp_data("flusurvnet", "50-64y", years=2010:2014)
#' }
get_hosp_data <- function(area="flusurvnet", age_group="overall",
years=as.numeric(format(Sys.Date(), "%Y")) - 1) {


+ 4
- 5
R/get-state-data.r View File

@ -18,12 +18,11 @@
#' is not due to a large download size, but the time it takes for their
#' servers to crunch the data. Wrap the function call in \code{httr::with_verbose}
#' if you would like to see what's going on.
#' @examples
#' get_state_data(2014)
#' @examples
#' state_data <- get_state_data(2014)
#' \dontrun{
#' get_state_data(c(2013, 2014))
#' get_state_data(2010:2014)
#' httr::with_verbose(get_state_data(2009:2015))
#' gsd <- get_state_data(c(2013, 2014))
#' gsd <- get_state_data(2010:2014)
#' }
get_state_data <- function(years=as.numeric(format(Sys.Date(), "%Y"))) {


+ 4
- 2
R/get-weekly-flu-report.r View File

@ -15,7 +15,7 @@
#' \code{label}, \code{subtitle}
#' @export
#' @examples \dontrun{
#' get_weekly_flu_report()
#' wfr <- get_weekly_flu_report()
#' }
get_weekly_flu_report <- function() {
@ -28,6 +28,8 @@ get_weekly_flu_report <- function() {
# for each period extract the state information and
# shove it all into a data frame
pb <- dplyr::progress_estimated(length(periods))
suppressWarnings(suppressMessages(
purrr::map_df(periods, function(period) {
pb$tick()$print()
@ -51,7 +53,7 @@ get_weekly_flu_report <- function() {
subtitle = period["subtitle"]
)
}) -> out
}) -> out))
class(out) <- c("cdcweeklyreport", class(out))


+ 5
- 4
R/hospital.r View File

@ -16,7 +16,7 @@
#' @references
#' - [Hospital Portal](https://gis.cdc.gov/GRASP/Fluview/FluHospRates.html)
#' @export
#' @examples
#' @examples
#' hosp_fs <- hospitalizations("flusurv", years=2015)
#' \dontrun{
#' hosp_eip <- hospitalizations("eip")
@ -76,16 +76,17 @@ hospitalizations <- function(surveillance_area=c("flusurv", "eip", "ihsp"),
ser_names <- unlist(hosp$res$busdata$datafields, use.names = FALSE)
mmwr_df <- bind_rows(hosp$res$mmwr)
suppressWarnings(suppressMessages(mmwr_df <- dplyr::bind_rows(hosp$res$mmwr)))
mmwr_df <- mmwr_df[,c("mmwrid", "weekend", "weeknumber", "weekstart", "year",
"yearweek", "seasonid", "weekendlabel", "weekendlabel2")]
suppressMessages(suppressWarnings(
dplyr::bind_rows(lapply(hosp$res$busdata$dataseries, function(.x) {
tdf <- dplyr::bind_rows(lapply(.x$data, function(.x) setNames(.x, ser_names)))
tdf$age <- .x$age
tdf$season <- .x$season
tdf
})) -> xdf
})) -> xdf))
dplyr::left_join(xdf, mmwr_df, c("mmwrid", "weeknumber")) %>%
dplyr::left_join(age_df, "age") %>%
@ -137,7 +138,7 @@ hospitalizations <- function(surveillance_area=c("flusurv", "eip", "ihsp"),
#' @md
#' @export
#' @examples
#' surveillance_areas()
#' sa <- surveillance_areas()
surveillance_areas <- function() {
meta <- jsonlite::fromJSON("https://gis.cdc.gov/GRASP/Flu3/GetPhase03InitApp?appVersion=Public")
xdf <- setNames(meta$catchments[,c("name", "area")], c("surveillance_area", "region"))


+ 2
- 2
R/ili-weekly-state.r View File

@ -25,7 +25,7 @@
#' with data presented by the state likely being the more complete.
#' @export
#' @examples \dontrun{
#' ili_weekly_activity_indicators(2016)
#' iwai <- ili_weekly_activity_indicators(2016)
#' }
ili_weekly_activity_indicators <- function(years=NULL) {
@ -78,7 +78,7 @@ ili_weekly_activity_indicators <- function(years=NULL) {
#' @md
#' @export
#' @examples
#' state_data_providers()
#' sdp <- state_data_providers()
state_data_providers <- function() {
jsonlite::fromJSON("https://gis.cdc.gov/grasp/fluView1/Phase1IniP") %>%


+ 2
- 5
R/ilinet.r View File

@ -28,11 +28,8 @@
#' census_ili <- ilinet("census")
#' state_ili <- ilinet("state")
#'
#' library(purrr)
#' map_df(
#' c("national", "hhs", "census", "state"),
#' ~ ilinet(.x)
#' )
#' all_ili <- suppressWarnings(
#' suppressMessages(purrr::map_df(c("national", "hhs", "census", "state"), ilinet)))
#' }
ilinet <- function(region = c("national", "hhs", "census", "state"), years = NULL) {


+ 3
- 3
R/mmwr-map.r View File

@ -53,7 +53,7 @@ NULL
#' @return data frame (tibble)
#' @export
#' @examples
#' mmwr_week(Sys.Date())
#' mwk <- mmwr_week(Sys.Date())
mmwr_week <- function(x) {
x <- as.Date(x)
x <- setNames(MMWRweek::MMWRweek(x), c("mmwr_year", "mmwr_week", "mmwr_day"))
@ -76,7 +76,7 @@ mmwr_week <- function(x) {
#' @return ordered factor
#' @export
#' @examples
#' mmwr_weekday(Sys.Date())
#' mwday <- mmwr_weekday(Sys.Date())
mmwr_weekday <- function(x, abbr = FALSE) {
x <- as.Date(x)
x <- MMWRweek::MMWRweekday(x)
@ -103,7 +103,7 @@ mmwr_weekday <- function(x, abbr = FALSE) {
#' @return vector of `Date` objects
#' @export
#' @examples
#' mmwr_week_to_date(2016,10,3)
#' mwd <- mmwr_week_to_date(2016,10,3)
mmwr_week_to_date <- function(year, week, day=NULL) {
year <- as.numeric(year)


+ 2
- 2
R/pi-mortality.r View File

@ -114,11 +114,11 @@ pi_mortality <- function(coverage_area=c("national", "state", "region"), years=N
res <- httr::content(res, as="parsed", flatten=TRUE)
dplyr::bind_rows(res$seasons) %>%
suppressWarnings(suppressMessages(dplyr::bind_rows(res$seasons) %>%
dplyr::left_join(mapcode_df, "map_code") %>%
dplyr::left_join(geo_df, "geoid") %>%
dplyr::left_join(age_df, "ageid") %>%
dplyr::left_join(dplyr::mutate(mmwrid_map, mmwrid=as.character(mmwrid)), "mmwrid") -> xdf
dplyr::left_join(dplyr::mutate(mmwrid_map, mmwrid=as.character(mmwrid)), "mmwrid") -> xdf))
xdf <- dplyr::mutate(xdf, coverage_area = coverage_area)


+ 0
- 4
R/zzz.r View File

@ -7,8 +7,4 @@
"See https://github.com/hrbrmstr/cdcfluview for info/news."))
}
# packageStartupMessage(paste0("cdcfluview is under *active* development. ",
# "There are numerous changes & dprecations.\n",
# "See https://github.com/hrbrmstr/cdcfluview for info/news."))
} # nocov end

+ 1
- 1
man/age_group_distribution.Rd View File

@ -20,7 +20,7 @@ public health laboratories by influenza virus type and subtype/lineage. Laborato
from multiple seasons and different age groups is provided.
}
\examples{
age_group_distribution(years=2015)
agd <- age_group_distribution(years=2015)
}
\references{
\itemize{


+ 1
- 1
man/geographic_spread.Rd View File

@ -20,6 +20,6 @@ State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
}
\examples{
\dontrun{
geographic_spread()
gs <- geographic_spread()
}
}

+ 0
- 5
man/get_flu_data.Rd View File

@ -48,8 +48,3 @@ There is often a noticeable delay when making the API request to the CDC.
servers to crunch the data. Wrap the function call in \code{httr::with_verbose}
if you would like to see what's going on.
}
\examples{
\dontrun{
flu <- get_flu_data("hhs", 1:10, c("who", "ilinet"), years=2000:2014)
}
}

+ 1
- 1
man/get_hosp_data.Rd View File

@ -38,6 +38,6 @@ There is often a noticeable delay when making the API request to the CDC.
\examples{
\dontrun{
# All of FluSurv-NET, 50-64 years old, 2010/11-2014/15 flu seasons
flu <- get_hosp_data("flusurvnet", "50-64y", years=2010:2014)
hosp <- get_hosp_data("flusurvnet", "50-64y", years=2010:2014)
}
}

+ 3
- 4
man/get_state_data.Rd View File

@ -31,10 +31,9 @@ There is often a noticeable delay when making the API request to the CDC. This
if you would like to see what's going on.
}
\examples{
get_state_data(2014)
state_data <- get_state_data(2014)
\dontrun{
get_state_data(c(2013, 2014))
get_state_data(2010:2014)
httr::with_verbose(get_state_data(2009:2015))
gsd <- get_state_data(c(2013, 2014))
gsd <- get_state_data(2010:2014)
}
}

+ 1
- 1
man/get_weekly_flu_report.Rd View File

@ -23,7 +23,7 @@ the reporting source metadata and a limit on the historical flu information.
}
\examples{
\dontrun{
get_weekly_flu_report()
wfr <- get_weekly_flu_report()
}
}
\references{


+ 1
- 1
man/ili_weekly_activity_indicators.Rd View File

@ -35,7 +35,7 @@ with data presented by the state likely being the more complete.
}
\examples{
\dontrun{
ili_weekly_activity_indicators(2016)
iwai <- ili_weekly_activity_indicators(2016)
}
}
\references{


+ 2
- 5
man/ilinet.Rd View File

@ -33,11 +33,8 @@ hhs_ili <- ilinet("hhs")
census_ili <- ilinet("census")
state_ili <- ilinet("state")
library(purrr)
map_df(
c("national", "hhs", "census", "state"),
~ ilinet(.x)
)
all_ili <- suppressWarnings(
suppressMessages(purrr::map_df(c("national", "hhs", "census", "state"), ilinet)))
}
}
\references{


+ 1
- 1
man/mmwr_week.Rd View File

@ -17,5 +17,5 @@ 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())
mwk <- mmwr_week(Sys.Date())
}

+ 1
- 1
man/mmwr_week_to_date.Rd View File

@ -20,5 +20,5 @@ of \code{Date} objects that corresponds to the input MMWR year+week or year+week
vectors. This also adds some parameter checking and cleanup to avoid exceptions.
}
\examples{
mmwr_week_to_date(2016,10,3)
mwd <- mmwr_week_to_date(2016,10,3)
}

+ 1
- 1
man/mmwr_weekday.Rd View File

@ -25,5 +25,5 @@ Weekday names are explicitly mapped to "Sunday-Saturday" or "Sun-Sat" and
do not change with your locale.
}
\examples{
mmwr_weekday(Sys.Date())
mwday <- mmwr_weekday(Sys.Date())
}

+ 1
- 1
man/state_data_providers.Rd View File

@ -10,5 +10,5 @@ state_data_providers()
Retrieve metadata about U.S. State CDC Provider Data
}
\examples{
state_data_providers()
sdp <- state_data_providers()
}

+ 1
- 1
man/surveillance_areas.Rd View File

@ -10,5 +10,5 @@ surveillance_areas()
Retrieve a list of valid sub-regions for each surveillance area.
}
\examples{
surveillance_areas()
sa <- surveillance_areas()
}

Loading…
Cancel
Save