Package 'owidapi'

Title: Access the Our World in Data Chart API
Description: Retrieve data from the Our World in Data (OWID) Chart API <https://docs.owid.io/projects/etl/api/>. OWID provides public access to more than 4,000 charts focusing on global problems such as poverty, disease, hunger, climate change, war, existential risks, and inequality.
Authors: Christoph Scheuch [aut, cre, cph] (ORCID: <https://orcid.org/0009-0004-0423-6819>)
Maintainer: Christoph Scheuch <[email protected]>
License: MIT + file LICENSE
Version: 0.1.2.9000
Built: 2026-09-26 09:38:49 UTC
Source: https://github.com/tidy-intelligence/r-owidapi

Help Index


Embed Our World in Data Chart in HTML

Description

[Experimental]

Creates HTML code to embed an interactive chart from Our World in Data into an HTML document using an iframe.

Usage

owid_embed(url, width = "100%", height = "600px")

Arguments

url

A character string containing the URL of the Our World in Data chart. Must begin with "https://ourworldindata.org/grapher/".

width

A character string specifying the width of the iframe. Default is "100%".

height

A character string specifying the height of the iframe. Default is "600px".

Value

A character string containing the HTML iframe to embed the chart.

Examples

owid_embed(
  "https://ourworldindata.org/grapher/co2-emissions-per-capita",
  width = "90%",
  height = "500px"
)

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

Download data catalog of Our World in Data

Description

Downloads the data catalog of Our World in Data (OWID) hosted on Datasette. The catalog is retrieved page by page, so the complete set of charts is returned rather than just the first page.

Usage

owid_get_catalog(snake_case = TRUE)

Arguments

snake_case

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

Value

A tibble containing the OWID catalog, with one row per chart.

Examples

# Download a full table
owid_get_catalog()

Download metadata from Our World in Data

Description

Retrieves the metadata for a data set from Our World in Data (OWID) by specifying a chart identifier or direct URL.

Usage

owid_get_metadata(chart_id = NULL, url = NULL)

Arguments

chart_id

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

url

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

Value

A list containing the requested OWID metadata.

Examples

# Download metadata using a data set
owid_get_metadata("life-expectancy")

# Download metadata using an url
owid_get_metadata(
 url = "https://ourworldindata.org/grapher/civil-liberties-score-fh"
)

Create OWID chart output elements in Shiny

Description

[Experimental]

This function creates an HTML output element for embedding Our World in Data (OWID) charts in a Shiny application. It should be used in the UI definition of your Shiny app.

Usage

owid_output(id)

owid_server(id, url, width = "100%", height = "600px")

Arguments

id

Character string. The ID of the output element.

url

Character string. The URL of the OWID chart to embed.

width

Character string. The width of the chart (default: "100%").

height

Character string. The height of the chart (default: "600px").

Value

A Shiny HTML output element where the OWID chart will be rendered.

Examples

library(shiny)

ui <- fluidPage(
 owid_output("gdp_chart"),
 owid_output("co2_chart")
)

server <- function(input, output) {
 owid_server(
   "gdp_chart",
   "https://ourworldindata.org/grapher/gdp-per-capita-worldbank?tab=line"
 )
 owid_server(
   "co2_chart",
   "https://ourworldindata.org/grapher/co2-emissions-per-capita",
   height = "500px"
 )
}

shinyApp(ui = ui, server = server)