Browse Source

added years parameter to who-nvress

tags/v0.7.0
boB Rudis 3 years ago
parent
commit
4c86235cca
No known key found for this signature in database GPG Key ID: 2A514A4997464560
2 changed files with 25 additions and 4 deletions
  1. +24
    -3
      R/who-nrvess.r
  2. +1
    -1
      man/who_nrevss.Rd

+ 24
- 3
R/who-nrvess.r View File

@ -31,10 +31,12 @@
#' census_who <- who_nrevss("census")
#' state_who <- who_nrevss("state")
#' }
who_nrevss <- function(region=c("national", "hhs", "census", "state")) {
who_nrevss <- function(region=c("national", "hhs", "census", "state"), years=NULL) {
region <- match.arg(tolower(region), c("national", "hhs", "census", "state"))
meta <- jsonlite::fromJSON("https://gis.cdc.gov/grasp/flu2/GetPhase02InitApp?appVersion=Public")
list(
AppVersion = "Public",
DatasourceDT = list(list(ID = 1, Name = "WHO_NREVSS")),
@ -49,8 +51,27 @@ who_nrevss <- function(region=c("national", "hhs", "census", "state")) {
state = { lapply(1:59, function(i) list(ID=i, Name=as.character(i))) }
)
seasons <- 37:((unclass(as.POSIXlt(Sys.time()))[["year"]] + 1900) - 1960)
params$SeasonsDT <- lapply(seasons, function(i) list(ID=i, Name=as.character(i)))
available_seasons <- sort(meta$seasons$seasonid)
if (is.null(years)) { # ALL YEARS
years <- available_seasons
} else { # specified years or seasons or a mix
years <- as.numeric(years)
years <- ifelse(years > 1996, years - 1960, years)
years <- sort(unique(years))
years <- years[years %in% available_seasons]
if (length(years) == 0) {
years <- rev(sort(meta$seasons$seasonid))[1]
curr_season_descr <- meta$seasons[meta$seasons$seasonid == years, "description"]
message(sprintf("No valid years specified, defaulting to this flu season => ID: %s [%s]",
years, curr_season_descr))
}
}
params$SeasonsDT <- lapply(years, function(i) list(ID=i, Name=as.character(i)))
tf <- tempfile(fileext = ".zip")
td <- tempdir()


+ 1
- 1
man/who_nrevss.Rd View File

@ -4,7 +4,7 @@
\alias{who_nrevss}
\title{Retrieve WHO/NREVSS Surveillance Data}
\usage{
who_nrevss(region = c("national", "hhs", "census", "state"))
who_nrevss(region = c("national", "hhs", "census", "state"), years = NULL)
}
\arguments{
\item{region}{one of "\code{national}", "\code{hhs}", "\code{census}", or "\code{state}"}


Loading…
Cancel
Save