get_us_states_covid_stats: Get COVID-19 Statistics for U.S. States and Territories

View source: R/get_us_states_covid_stats.R

get_us_states_covid_statsR Documentation

Get COVID-19 Statistics for U.S. States and Territories

Description

Retrieves real-time COVID-19 totals from the 'disease.sh' API for all 50 U.S. states, as well as U.S. territories (e.g., Puerto Rico, Guam), special jurisdictions (e.g., Veteran Affairs, U.S. Military), and others (e.g., cruise ships, repatriated individuals).

Usage

get_us_states_covid_stats()

Details

This function sends a GET request to the 'disease.sh' API endpoint for US state-level COVID-19 statistics and parses the response into a structured data frame. The timestamp is converted to a readable date-time format (in UTC). Requires an active internet connection.

Value

A data frame with the following columns:

  • state: Name of the U.S. state.

  • cases: Total confirmed cases in the state.

  • todayCases: New confirmed cases today.

  • deaths: Total deaths in the state.

  • todayDeaths: New deaths today.

  • active: Current active cases.

  • population: Estimated state population.

Returns NULL if the API is unavailable or an error occurs.

Note

An internet connection is required to use this function. Function fails gracefully if API is unavailable.

References

API Docs: https://disease.sh/docs/#/COVID-19:

Examples

## Not run: 
us_states_stats <- get_us_states_covid_stats()
if (!is.null(us_states_stats)) {
  head(us_states_stats)
}

## End(Not run)


infectiousR documentation built on Nov. 9, 2025, 5:07 p.m.