Title: | Access the Our World in Data Chart API |
Version: | 0.1.1 |
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 5,000 charts focusing on global problems such as poverty, disease, hunger, climate change, war, existential risks, and inequality. |
License: | MIT + file LICENSE |
Depends: | R (≥ 4.1) |
Imports: | cli (≥ 3.0.0), httr2 (≥ 1.0.0), jsonlite (≥ 1.0.0), lifecycle, tibble, utils, rlang |
Suggests: | curl, shiny, testthat (≥ 3.0.0) |
URL: | https://github.com/tidy-intelligence/r-owidapi, https://tidy-intelligence.github.io/r-owidapi/ |
BugReports: | https://github.com/tidy-intelligence/r-owidapi/issues |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-06-23 14:25:20 UTC; krise |
Author: | Christoph Scheuch |
Maintainer: | Christoph Scheuch <christoph@tidy-intelligence.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-23 14:50:01 UTC |
owidapi: 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 5,000 charts focusing on global problems such as poverty, disease, hunger, climate change, war, existential risks, and inequality.
Author(s)
Maintainer: Christoph Scheuch christoph@tidy-intelligence.com (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/tidy-intelligence/r-owidapi/issues
Embed Our World in Data Chart in HTML
Description
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 |
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, |
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.
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.
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 |
Direct URL to an OWID chart. If provided, |
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
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)
Search for keywords in OWID catalog data
Description
This function searches for a vector of keywords within specified columns of an OWID catalog data frame. If no columns are specified, it searches all character and factor columns.
Usage
owid_search(data, keywords, columns = NULL)
Arguments
data |
A data frame, typically obtained from owid_get_catalog. |
keywords |
A character vector of one or more keywords to search for. The search is case-insensitive. |
columns |
An optional character vector of column names to search within. If NULL (default), all character and factor columns are searched. |
Value
A filtered data frame containing only rows that match at least one of the keywords in at least one of the specified columns.
Examples
# Get the OWID catalog
catalog <- owid_get_catalog()
# Search for climate or carbon in all text columns
owid_search(catalog, c("climate", "carbon"))
# Search only in the title column
owid_search(catalog, c("climate", "carbon"), c("title"))