| Title: | Download and Tidy Data from the OECD |
| Version: | 0.3.0 |
| Description: | Provides clean, tidy access to key economic indicators published by the Organisation for Economic Co-operation and Development (OECD), covering GDP, CPI inflation, unemployment, tax revenue, government deficit, health expenditure, education expenditure, income inequality, labour productivity, and current account balance across all 38 OECD member countries. Data is downloaded from the OECD Data Explorer API https://data-explorer.oecd.org on first use and cached locally for subsequent calls. Returns tidy long-format data frames ready for analysis and visualisation. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-GB |
| URL: | https://github.com/charlescoverdale/readoecd |
| BugReports: | https://github.com/charlescoverdale/readoecd/issues |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 4.1.0) |
| Imports: | httr2, cli |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-03-07 18:57:32 UTC; charlescoverdale |
| Author: | Charles Coverdale [aut, cre] |
| Maintainer: | Charles Coverdale <charlesfcoverdale@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-12 08:10:09 UTC |
Check OECD API connectivity
Description
Tests the OECD API by making a small live request. Useful for diagnosing connectivity issues or confirming the API is responding normally.
Usage
check_oecd_api()
Value
Invisibly returns TRUE if the API is reachable, otherwise throws
an error.
Examples
## Not run:
check_oecd_api()
## End(Not run)
Clear the readoecd local cache
Description
Deletes all files cached by readoecd on your local machine. After
clearing, the next call to any get_oecd_*() function will re-download
from the OECD API.
Usage
clear_oecd_cache()
Value
Invisibly returns the number of files deleted.
Examples
clear_oecd_cache()
Get OECD CPI inflation data
Description
Downloads (and caches) annual consumer price inflation for OECD member countries from the OECD Prices database (COICOP 1999 classification).
Usage
get_oecd_cpi(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Returns the year-on-year percentage change in the Consumer Price Index (CPI) for total expenditure, not seasonally adjusted. This is the standard harmonised measure of headline inflation used for cross-country comparisons.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"CPI_INFLATION"(character)- value
Annual CPI inflation rate (numeric)
- unit
"% change, year-on-year"(character)
Examples
cpi <- get_oecd_cpi(c("AUS", "GBR", "USA"), start_year = 2000)
head(cpi)
Get OECD trade (balance of payments) data
Description
Downloads (and caches) annual current account balance data for OECD member countries from the OECD Balance of Payments (BOP) database.
Usage
get_oecd_current_account(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Returns the current account balance (credits minus debits) with the rest of the world, in millions of US dollars at current exchange rates. A positive value indicates a current account surplus; a negative value indicates a deficit.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"CURRENT_ACCOUNT"or"CURRENT_ACCOUNT_GOODS_SERVICES"(character)- value
Current account balance in millions USD (numeric)
- unit
"Millions USD (exchange rate)"(character)
Examples
trade <- get_oecd_current_account(c("AUS", "DEU", "USA"), start_year = 2000)
head(trade)
Get OECD government deficit data
Description
Downloads (and caches) general government net lending/borrowing as a share of GDP for OECD member countries from the OECD National Accounts (NAAG) database.
Usage
get_oecd_deficit(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Net lending/borrowing is the difference between government revenue and expenditure, expressed as a percentage of GDP. A positive value indicates a surplus (government saving); a negative value indicates a deficit (government borrowing). This is the standard fiscal balance measure used for cross-country comparisons and is consistent with the System of National Accounts (SNA) definition.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"GOVT_NET_LENDING"(character)- value
Net lending/borrowing as a share of GDP (numeric). Positive = surplus; negative = deficit.
- unit
"% of GDP"(character)
Examples
deficit <- get_oecd_deficit(c("AUS", "GBR", "USA"), start_year = 2000)
head(deficit)
Get OECD education expenditure data
Description
Downloads (and caches) total education expenditure as a share of GDP for OECD member countries from the OECD Education at a Glance (EAG) UOE Finance database.
Usage
get_oecd_education(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Education expenditure covers spending on educational institutions across all levels of education (ISCED 0–8), from all public and private sources, expressed as a percentage of GDP.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"EDU_EXPENDITURE"(character)- value
Total education expenditure as a share of GDP (numeric)
- unit
"% of GDP"(character)
Examples
edu <- get_oecd_education(c("AUS", "GBR", "USA"), start_year = 2000)
head(edu)
Get OECD GDP data
Description
Downloads (and caches) annual gross domestic product (GDP) at current prices for OECD member countries from the OECD National Accounts database.
Usage
get_oecd_gdp(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
GDP is measured using the expenditure approach (Table 1 of the OECD Main National Accounts), valued at current prices in US dollars converted using purchasing power parities (PPPs) where available.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"GDP"(character)- value
GDP value at current prices (numeric)
- unit
Unit of measurement (character)
Examples
gdp <- get_oecd_gdp(c("AUS", "GBR", "USA"), start_year = 2010)
# Largest OECD economies
latest <- gdp[gdp$year == max(gdp$year), ]
head(latest[order(-latest$value), c("country_name", "value")], 10)
Get OECD health expenditure data
Description
Downloads (and caches) total current health expenditure as a share of GDP for OECD member countries from the System of Health Accounts (SHA) database.
Usage
get_oecd_health(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Health expenditure covers all spending on health care goods and services across all financing sources (government, compulsory insurance, voluntary insurance, and out-of-pocket payments), measured as a percentage of GDP at current prices.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"HEALTH_EXPENDITURE"(character)- value
Total health expenditure as a share of GDP (numeric)
- unit
"% of GDP"(character)
Examples
health <- get_oecd_health(c("AUS", "GBR", "USA"), start_year = 2000)
head(health)
Get OECD income inequality data
Description
Downloads (and caches) the Gini coefficient of disposable income for OECD member countries from the OECD Income Distribution Database (IDD).
Usage
get_oecd_inequality(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
The Gini coefficient measures income inequality on a scale from 0 (perfect equality) to 1 (maximum inequality). Disposable income is household income after taxes and transfers. The series follows the OECD METH2012 methodology where available for consistency across countries and time.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"GINI"(character)- value
Gini coefficient of disposable income (numeric)
- unit
"Gini coefficient (0-1)"(character)
Examples
gini <- get_oecd_inequality(c("AUS", "GBR", "USA", "DNK"), start_year = 2000)
head(gini)
Get OECD productivity data
Description
Downloads (and caches) labour productivity data for OECD member countries from the OECD Productivity Database (PDB).
Usage
get_oecd_productivity(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Returns GDP per hour worked where available (in USD purchasing power parities), falling back to GDP per capita. Values are at current prices.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"GDP_PER_HOUR"or"GDP_PER_CAPITA"(character)- value
Productivity value (numeric)
- unit
Unit of measurement (character)
Examples
prod <- get_oecd_productivity(c("AUS", "GBR", "USA"), start_year = 2000)
head(prod)
Get OECD tax revenue data
Description
Downloads (and caches) total tax revenue as a share of GDP for OECD member countries from the OECD Revenue Statistics Comparator database.
Usage
get_oecd_tax(countries = "all", start_year = 1990, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- year
Calendar year (integer)
- series
"TAX_REVENUE"(character)- value
Total tax revenue as a share of GDP (numeric)
- unit
"% of GDP"(character)
Examples
tax <- get_oecd_tax(c("AUS", "GBR", "USA"), start_year = 2000)
head(tax)
Get OECD unemployment rates
Description
Downloads (and caches) monthly harmonised unemployment rates for OECD member countries from the OECD Labour Force Statistics database.
Usage
get_oecd_unemployment(countries = "all", start_year = 2000, refresh = FALSE)
Arguments
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Details
Returns the seasonally adjusted unemployment rate as a percentage of the labour force, for persons aged 15 and over (total, both sexes). This is the standard harmonised series used for cross-country comparisons.
Value
A data frame with columns:
- country
ISO 3166-1 alpha-3 country code (character)
- country_name
English country name (character)
- period
Calendar month in
"YYYY-MM"format (character)- series
"Unemployment rate"(character)- value
Unemployment rate as a percentage of the labour force (numeric)
- unit
"% of labour force"(character)
Examples
# All OECD members since 2010
une <- get_oecd_unemployment(start_year = 2010)
# Australia and UK since 2020
une <- get_oecd_unemployment(c("AUS", "GBR"), start_year = 2020)
# Which country had the highest unemployment in 2020?
une2020 <- une[startsWith(une$period, "2020"), ]
une2020_avg <- aggregate(value ~ country_name, une2020, mean)
head(une2020_avg[order(-une2020_avg$value), ], 5)
List OECD member countries
Description
Returns a data frame of the 38 OECD member countries with their ISO 3166-1 alpha-3 codes and English names. No network call is required.
Usage
list_oecd_countries()
Value
A data frame with columns:
- iso3
ISO 3166-1 alpha-3 country code (character)
- name
English country name (character)
Examples
list_oecd_countries()