get_global_covid_stats: Get Global COVID-19 Statistics

View source: R/get_global_covid_stats.R

get_global_covid_statsR Documentation

Get Global COVID-19 Statistics

Description

Retrieves real-time global statistics on COVID-19 from the 'disease.sh' API.

Usage

get_global_covid_stats()

Details

This function sends a GET request to the 'disease.sh' API and parses the returned JSON into a structured and user-friendly 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:

  • updated: Last updated time (as a human-readable date-time).

  • cases: Total confirmed cases worldwide.

  • newCases: Number of new confirmed cases today.

  • deaths: Total confirmed deaths worldwide.

  • recovered: Total number of recovered patients.

  • newRecov: Number of recovered patients today.

  • active: Current active cases.

  • critical: Current number of critical cases.

  • tests: Total number of tests performed.

  • pop: Estimated global population.

  • countries: Number of countries affected.

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: 
global_stats <- get_global_covid_stats()
if (!is.null(global_stats)) {
  print(global_stats)
}

## End(Not run)


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