Skip to contents

This function reads target data either from the hub's time-series file using hubData or by pulling data from NHSN and NSSP APIs, then writes to the weekly-summaries directory for use by the visualization webpage. Output includes columns: week_ending_date, location, location_name, target, target_data_type, and value.

Usage

write_viz_target_data(
  reference_date,
  base_hub_path,
  hub_reports_path,
  disease,
  use_hub_data = FALSE,
  as_of = "latest",
  pull_nhsn = TRUE,
  pull_nssp = TRUE,
  start_date = NULL,
  end_date = NULL,
  included_locations = hubhelpr::included_locations,
  output_format = "csv"
)

Arguments

reference_date

Character, the reference date for the forecast in YYYY-MM-DD format (ISO-8601).

base_hub_path

Character, path to the forecast hub directory.

hub_reports_path

Character, path to forecast hub reports directory.

disease

Character, disease name ("covid" or "rsv").

use_hub_data

Logical, whether to read data from the hub's time-series file (TRUE) or pull fresh data from sources (FALSE). Default: FALSE.

as_of

As of date to filter to, as an object coercible by as.Date(), or "latest" to filter to the most recent available vintage. Default "latest". Used only when use_hub_data = TRUE.

pull_nhsn

Logical, whether to pull NHSN hospital admissions data. Default: TRUE. Used only when use_hub_data = FALSE.

pull_nssp

Logical, whether to pull NSSP emergency department visit data. Default: TRUE. Used only when use_hub_data = FALSE.

start_date

Date, earliest date to include in data. Default: NULL (no filtering). Used only when use_hub_data = FALSE.

end_date

Date, latest date to include in data. Default: NULL (no filtering). Used only when use_hub_data = FALSE.

included_locations

Character vector of location codes to include in the output. Default hubhelpr::included_locations.

output_format

Character, output file format. One of "csv", "tsv", or "parquet". Default: "csv".

Value

Invisibly returns file path where data was written.