Learn R Programming

infectiousR (version 0.1.0)

get_covid_stats_by_country: Get COVID-19 Statistics for All Countries

Description

Retrieves real-time COVID-19 totals for all countries from the 'disease.sh' API.

Usage

get_covid_stats_by_country(
  yesterday = FALSE,
  twoDaysAgo = FALSE,
  sort = NULL,
  allowNull = FALSE
)

Value

A data frame containing:

  • country: Country name.

  • updated: Last updated timestamp (as POSIXct in UTC).

  • cases: Total confirmed cases.

  • todayCases: New confirmed cases today.

  • deaths: Total deaths.

  • todayDeaths: New deaths today.

  • population: Population estimate for each country.

Arguments

yesterday

Logical. If TRUE, retrieves data reported from the previous day. Default is FALSE.

twoDaysAgo

Logical. If TRUE, retrieves data reported two days ago. Default is FALSE.

sort

Character. Field to sort results by. Options include: "cases", "todayCases", "deaths", "recovered", "active", etc.

allowNull

Logical. If TRUE, missing values are returned as NA instead of 0. Default is FALSE.

Details

This function fetches COVID-19 summary statistics for each country. Useful for global surveillance or international comparisons.

References

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

Examples

Run this code
# \donttest{
# Get real-time COVID-19 data for all countries
get_covid_stats_by_country()

# Get sorted data by number of deaths reported yesterday
get_covid_stats_by_country(yesterday = TRUE, sort = "deaths")
# }

Run the code above in your browser using DataLab