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",
  start_date = NULL,
  end_date = NULL,
  included_locations = hubhelpr::included_locations,
  excluded_locations = NULL,
  output_format = "csv",
  overwrite_existing = FALSE
)

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.

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.

excluded_locations

Character vector or named list specifying US state abbreviations to exclude. If a character vector, locations are excluded across all targets. If a named list, names should be target names (or "all" for global exclusions) mapping to character vectors of abbreviations. Converted to hub codes internally. Default: NULL.

output_format

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

overwrite_existing

logical. If TRUE, overwrite existing files. Default: FALSE.

Value

Invisibly returns file path where data was written.