diff --git a/.travis.yml b/.travis.yml index 82b1af4..0c32f92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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()' diff --git a/R/agd-ipt.r b/R/agd-ipt.r index c54322f..c8c3e00 100644 --- a/R/agd-ipt.r +++ b/R/agd-ipt.r @@ -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( diff --git a/R/geographic-spread.R b/R/geographic-spread.R index 88afd72..b23d351 100644 --- a/R/geographic-spread.R +++ b/R/geographic-spread.R @@ -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 diff --git a/R/get-flu-data.r b/R/get-flu-data.r index acccdb9..1ed8d0e 100644 --- a/R/get-flu-data.r +++ b/R/get-flu-data.r @@ -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"))) { diff --git a/R/get-hosp-data.r b/R/get-hosp-data.r index f27af0a..158b4fd 100644 --- a/R/get-hosp-data.r +++ b/R/get-hosp-data.r @@ -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) { diff --git a/R/get-state-data.r b/R/get-state-data.r index 424535b..2f6b764 100644 --- a/R/get-state-data.r +++ b/R/get-state-data.r @@ -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"))) { diff --git a/R/get-weekly-flu-report.r b/R/get-weekly-flu-report.r index 006fb03..db79642 100644 --- a/R/get-weekly-flu-report.r +++ b/R/get-weekly-flu-report.r @@ -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)) diff --git a/R/hospital.r b/R/hospital.r index a935527..3cb1128 100644 --- a/R/hospital.r +++ b/R/hospital.r @@ -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")) diff --git a/R/ili-weekly-state.r b/R/ili-weekly-state.r index 3ec0edb..b6e757c 100644 --- a/R/ili-weekly-state.r +++ b/R/ili-weekly-state.r @@ -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") %>% diff --git a/R/ilinet.r b/R/ilinet.r index a5a0db1..1c43b24 100644 --- a/R/ilinet.r +++ b/R/ilinet.r @@ -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) { diff --git a/R/mmwr-map.r b/R/mmwr-map.r index e603509..2512b90 100644 --- a/R/mmwr-map.r +++ b/R/mmwr-map.r @@ -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) diff --git a/R/pi-mortality.r b/R/pi-mortality.r index bd5a5e2..d385bc3 100644 --- a/R/pi-mortality.r +++ b/R/pi-mortality.r @@ -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) diff --git a/R/zzz.r b/R/zzz.r index 861dd5a..727bb77 100644 --- a/R/zzz.r +++ b/R/zzz.r @@ -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 diff --git a/man/age_group_distribution.Rd b/man/age_group_distribution.Rd index d462f31..05e8e62 100644 --- a/man/age_group_distribution.Rd +++ b/man/age_group_distribution.Rd @@ -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{ diff --git a/man/geographic_spread.Rd b/man/geographic_spread.Rd index e83907f..360f8e0 100644 --- a/man/geographic_spread.Rd +++ b/man/geographic_spread.Rd @@ -20,6 +20,6 @@ State and Territorial Epidemiologists Reports of Geographic Spread of Influenza } \examples{ \dontrun{ -geographic_spread() +gs <- geographic_spread() } } diff --git a/man/get_flu_data.Rd b/man/get_flu_data.Rd index 8a012e6..fc0904e 100644 --- a/man/get_flu_data.Rd +++ b/man/get_flu_data.Rd @@ -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) -} -} diff --git a/man/get_hosp_data.Rd b/man/get_hosp_data.Rd index c841c1e..b4c4e08 100644 --- a/man/get_hosp_data.Rd +++ b/man/get_hosp_data.Rd @@ -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) } } diff --git a/man/get_state_data.Rd b/man/get_state_data.Rd index 075f29c..3a34cb7 100644 --- a/man/get_state_data.Rd +++ b/man/get_state_data.Rd @@ -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) } } diff --git a/man/get_weekly_flu_report.Rd b/man/get_weekly_flu_report.Rd index 5f4963a..0e0c8fc 100644 --- a/man/get_weekly_flu_report.Rd +++ b/man/get_weekly_flu_report.Rd @@ -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{ diff --git a/man/ili_weekly_activity_indicators.Rd b/man/ili_weekly_activity_indicators.Rd index 011e37f..2f09eb7 100644 --- a/man/ili_weekly_activity_indicators.Rd +++ b/man/ili_weekly_activity_indicators.Rd @@ -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{ diff --git a/man/ilinet.Rd b/man/ilinet.Rd index d631563..3fabd3d 100644 --- a/man/ilinet.Rd +++ b/man/ilinet.Rd @@ -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{ diff --git a/man/mmwr_week.Rd b/man/mmwr_week.Rd index fbc7e53..63a97b3 100644 --- a/man/mmwr_week.Rd +++ b/man/mmwr_week.Rd @@ -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()) } diff --git a/man/mmwr_week_to_date.Rd b/man/mmwr_week_to_date.Rd index 10d8c59..87b7852 100644 --- a/man/mmwr_week_to_date.Rd +++ b/man/mmwr_week_to_date.Rd @@ -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) } diff --git a/man/mmwr_weekday.Rd b/man/mmwr_weekday.Rd index 743a946..e4cfb01 100644 --- a/man/mmwr_weekday.Rd +++ b/man/mmwr_weekday.Rd @@ -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()) } diff --git a/man/state_data_providers.Rd b/man/state_data_providers.Rd index 1d860bb..98237a2 100644 --- a/man/state_data_providers.Rd +++ b/man/state_data_providers.Rd @@ -10,5 +10,5 @@ state_data_providers() Retrieve metadata about U.S. State CDC Provider Data } \examples{ -state_data_providers() +sdp <- state_data_providers() } diff --git a/man/surveillance_areas.Rd b/man/surveillance_areas.Rd index 686f8ca..ae05c7e 100644 --- a/man/surveillance_areas.Rd +++ b/man/surveillance_areas.Rd @@ -10,5 +10,5 @@ surveillance_areas() Retrieve a list of valid sub-regions for each surveillance area. } \examples{ -surveillance_areas() +sa <- surveillance_areas() }