Browse Source

get_flu_data() will choose current flu season if years parameter is set to the current year but has no return data (i.e. the "next year's" flu season hasn't started)

tags/v0.5.2
boB Rudis 7 years ago
parent
commit
0912f15f1c
  1. 4
      DESCRIPTION
  2. 8
      NEWS.md
  3. 14
      R/get_flu_data.r

4
DESCRIPTION

@ -1,8 +1,8 @@
Package: cdcfluview Package: cdcfluview
Type: Package Type: Package
Title: Retrieve U.S. Flu Season Data from the CDC FluView Portal Title: Retrieve U.S. Flu Season Data from the CDC FluView Portal
Version: 0.5.1 Version: 0.5.2
Date: 2016-12-06 Date: 2017-01-02
Author: Bob Rudis (bob@rud.is) Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is> Maintainer: Bob Rudis <bob@rud.is>
Encoding: UTF-8 Encoding: UTF-8

8
NEWS.md

@ -1,4 +1,10 @@
# cscfluview 0.5.1 # cdcfluview 0.5.2
* Modified behavior of `get_flu_data()` to actually grab current flu season year
if a single year was specified and it is the current year and the return is a 0 length
data frame #7
# cdcfluview 0.5.1
* Replaced `http` URLs with `https` as `http` ones no longer work (fixes #6) * Replaced `http` URLs with `https` as `http` ones no longer work (fixes #6)
* Fixed State data download (CDC changed the hidden API) * Fixed State data download (CDC changed the hidden API)

14
R/get_flu_data.r

@ -98,7 +98,19 @@ get_flu_data <- function(region="hhs", sub_region=1:10,
names(file_list) <- substr(basename(files), 1, 3) names(file_list) <- substr(basename(files), 1, 3)
if (length(file_list) == 1) { if (length(file_list) == 1) {
return(file_list[[1]])
file_list <- file_list[[1]]
if ((nrow(file_list) == 0) &
(length(years)==1) &
(years == (as.numeric(format(Sys.Date(), "%Y"))-1960))) {
message("Adjusting [years] to get current season...")
return(get_flu_data(region=region, sub_region=sub_region,
data_source=data_source, years=years+1960-1))
} else {
return(file_list)
}
} else { } else {
return(file_list) return(file_list)
} }

Loading…
Cancel
Save