Learn R Programming

infectiousR (version 0.1.0)

get_us_states_covid_stats: 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()

Arguments

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.

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).

References

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

Examples

Run this code
# \donttest{
us_states_stats <- get_us_states_covid_stats()
head(us_states_stats)
# }

Run the code above in your browser using DataLab