owid_get: Download data from Our World in Data

View source: R/owid_get.R

owid_getR Documentation

Download data from Our World in Data

Description

Retrieves data from Our World in Data (OWID) by specifying a chart identifier or direct URL. Allows filtering by entities and time periods.

Usage

owid_get(
  chart_id = NULL,
  entities = NULL,
  start_date = NULL,
  end_date = NULL,
  url = NULL,
  use_column_short_names = TRUE,
  snake_case = TRUE
)

Arguments

chart_id

Character string specifying the chart identifier (e.g., "life-expectancy"). Not required if url is provided.

entities

Vector of entity codes (e.g., c("USA", "DEU")). If NULL, data for all available entities is returned.

start_date

Start date for filtering data. Can be a date string or a year. If NULL, starts from the earliest available data.

end_date

End date for filtering data. Can be a date string or a year. If NULL, ends with the latest available data.

url

Direct URL to an OWID dataset. If provided, chart_id is ignored.

use_column_short_names

Logical. If TRUE (default), uses short column names.

snake_case

Logical. If TRUE (default), converts column names to lowercase.

Value

A tibble containing the requested OWID data.

Examples



# Download a full table
owid_get("life-expectancy")

# Download a table only for selected entities
owid_get("life-expectancy", c("AUS", "AUT", "GER"))

# Download a table only for selected time periods
owid_get("life-expectancy", c("USA"), 1970, 1980)

# Download daily data for selected time periods
owid_get(
 "daily-covid-vaccination-doses-per-capita", "DEU",
 "2020-12-28", "2020-12-31"
)

# Download a table by just providing an URL (with or without .csv)
owid_get(
 url = paste0(
   "https://ourworldindata.org/grapher/civil-liberties-score-fh",
   "?tab=chart&time=earliest..2023&country=ARG~AUS~BWA~CHN~ALB~DEU"
 )
)
owid_get(
 url = paste0(
   "https://ourworldindata.org/grapher/civil-liberties-score-fh.csv",
   "?tab=chart&time=earliest..2023"
 )
)



owidapi documentation built on April 12, 2025, 2:22 a.m.