Skip to contents

Pull relevant epidemiological data from NHSN, defaulting to the HealthData.gov public API endpoint.

Usage

pull_nhsn(
  api_endpoint = "https://healthdata.gov/resource/g62h-syeh.json",
  api_key_id = NULL,
  api_key_secret = NULL,
  start_date = NULL,
  end_date = NULL,
  columns = NULL,
  states = NULL,
  order_by = c("state", "date"),
  desc = FALSE,
  limit = 1e+05,
  error_on_limit = TRUE,
  ...
)

Arguments

api_endpoint

API endpoint to use. Defaults to the HTTPS:// Socrata endpoint for HHS Protect / NHSN on HealthData.gov as of 2023-10-23, namely [https://healthdata.gov/resource/g62h-syeh]

api_key_id

Key ID of an API key to use when querying the dataset. Not required, but polite and reduces throttling. You can create one at https://healthdata.gov/profile/edit/developer_settings. Default NULL (no API key).

api_key_secret

Associated key secret for the API key given in api_key_id. Default NULL (no API key).

start_date

Pull only rows with dates greater than or equal to this date. If NULL, no minimum date. Default NULL.

end_date

Pull only rows with dates less than or equal to this date. If NULL, no maximum date. Default NULL.

columns

Vector of columns to retrieve, in addition to date and state, which are always retrieved. If NULL, retrieve all columns. Default NULL.

states

value or values to filter on for the state column of the NHSN dataset. If NULL, do not filter on that column. Default NULL.

order_by

column or columns to order (sort) by. Default c("state", "date") (sort first by state, then by date).

desc

Boolean. Whether to order descending instead of ascending. Default FALSE (order ascending).

limit

maximum number of rows to return. Default 1e5 (100000)

error_on_limit

Boolean. Raise an error if the number of rows returned is equal to the maximum? Default TRUE. This ensures that one does not silently end up with a subset of the total set of rows matching the query. If a subset is desired, one can set error_on_limit = FALSE.

...

other arguments passed to nhsn_soda_query()

Value

the pulled data, as a tibble::tibble().