| Title: | Download and Tidy Data from the 'OECD' |
|---|---|
| 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. |
| Authors: | Charles Coverdale [aut, cre] |
| Maintainer: | Charles Coverdale <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.4 |
| Built: | 2026-06-03 06:40:54 UTC |
| Source: | https://github.com/charlescoverdale/readoecd |
Tests the OECD API by making a small live request. Useful for diagnosing connectivity issues or confirming the API is responding normally.
check_oecd_api()check_oecd_api()
Invisibly returns TRUE if the API is reachable, otherwise throws
an error.
Other utilities:
clear_oecd_cache(),
list_oecd_countries()
## Not run: check_oecd_api() ## End(Not run)## Not run: check_oecd_api() ## End(Not run)
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.
clear_oecd_cache()clear_oecd_cache()
Invisibly returns the number of files deleted.
Other utilities:
check_oecd_api(),
list_oecd_countries()
op <- options(readoecd.cache_dir = tempdir()) clear_oecd_cache() options(op)op <- options(readoecd.cache_dir = tempdir()) clear_oecd_cache() options(op)
Downloads (and caches) annual consumer price inflation for OECD member countries from the OECD Prices database (COICOP 1999 classification).
get_oecd_cpi(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_cpi(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"CPI_INFLATION" (character)
Annual CPI inflation rate (numeric)
"% change, year-on-year" (character)
Other economic indicators:
get_oecd_gdp(),
get_oecd_unemployment()
op <- options(readoecd.cache_dir = tempdir()) cpi <- try(get_oecd_cpi(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(cpi, "try-error")) head(cpi) options(op)op <- options(readoecd.cache_dir = tempdir()) cpi <- try(get_oecd_cpi(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(cpi, "try-error")) head(cpi) options(op)
Downloads (and caches) annual current account balance data for OECD member countries from the OECD Balance of Payments (BOP) database.
get_oecd_current_account(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_current_account(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"CURRENT_ACCOUNT" or "CURRENT_ACCOUNT_GOODS_SERVICES"
(character)
Current account balance in millions USD (numeric)
"Millions USD (exchange rate)" (character)
Other productivity and trade:
get_oecd_productivity()
op <- options(readoecd.cache_dir = tempdir()) trade <- try(get_oecd_current_account(c("AUS", "DEU", "USA"), start_year = 2000)) if (!inherits(trade, "try-error")) head(trade) options(op)op <- options(readoecd.cache_dir = tempdir()) trade <- try(get_oecd_current_account(c("AUS", "DEU", "USA"), start_year = 2000)) if (!inherits(trade, "try-error")) head(trade) options(op)
Downloads (and caches) general government net lending/borrowing as a share of GDP for OECD member countries from the OECD National Accounts (NAAG) database.
get_oecd_deficit(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_deficit(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"GOVT_NET_LENDING" (character)
Net lending/borrowing as a share of GDP (numeric). Positive = surplus; negative = deficit.
"% of GDP" (character)
Other fiscal:
get_oecd_tax()
op <- options(readoecd.cache_dir = tempdir()) deficit <- try(get_oecd_deficit(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(deficit, "try-error")) head(deficit) options(op)op <- options(readoecd.cache_dir = tempdir()) deficit <- try(get_oecd_deficit(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(deficit, "try-error")) head(deficit) options(op)
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.
get_oecd_education(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_education(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"EDU_EXPENDITURE" (character)
Total education expenditure as a share of GDP (numeric)
"% of GDP" (character)
Other social indicators:
get_oecd_health(),
get_oecd_inequality()
op <- options(readoecd.cache_dir = tempdir()) edu <- try(get_oecd_education(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(edu, "try-error")) head(edu) options(op)op <- options(readoecd.cache_dir = tempdir()) edu <- try(get_oecd_education(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(edu, "try-error")) head(edu) options(op)
Downloads (and caches) annual gross domestic product (GDP) at current prices for OECD member countries from the OECD National Accounts database.
get_oecd_gdp(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_gdp(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"GDP" (character)
GDP value at current prices (numeric)
Unit of measurement (character)
Other economic indicators:
get_oecd_cpi(),
get_oecd_unemployment()
op <- options(readoecd.cache_dir = tempdir()) gdp <- try(get_oecd_gdp(c("AUS", "GBR", "USA"), start_year = 2010)) if (!inherits(gdp, "try-error")) { # Largest OECD economies latest <- gdp[gdp$year == max(gdp$year), ] head(latest[order(-latest$value), c("country_name", "value")], 10) } options(op)op <- options(readoecd.cache_dir = tempdir()) gdp <- try(get_oecd_gdp(c("AUS", "GBR", "USA"), start_year = 2010)) if (!inherits(gdp, "try-error")) { # Largest OECD economies latest <- gdp[gdp$year == max(gdp$year), ] head(latest[order(-latest$value), c("country_name", "value")], 10) } options(op)
Downloads (and caches) total current health expenditure as a share of GDP for OECD member countries from the System of Health Accounts (SHA) database.
get_oecd_health(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_health(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"HEALTH_EXPENDITURE" (character)
Total health expenditure as a share of GDP (numeric)
"% of GDP" (character)
Other social indicators:
get_oecd_education(),
get_oecd_inequality()
op <- options(readoecd.cache_dir = tempdir()) health <- try(get_oecd_health(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(health, "try-error")) head(health) options(op)op <- options(readoecd.cache_dir = tempdir()) health <- try(get_oecd_health(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(health, "try-error")) head(health) options(op)
Downloads (and caches) the Gini coefficient of disposable income for OECD member countries from the OECD Income Distribution Database (IDD).
get_oecd_inequality(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_inequality(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"GINI" (character)
Gini coefficient of disposable income (numeric)
"Gini coefficient (0-1)" (character)
Other social indicators:
get_oecd_education(),
get_oecd_health()
op <- options(readoecd.cache_dir = tempdir()) gini <- try(get_oecd_inequality(c("AUS", "GBR", "USA", "DNK"), start_year = 2000)) if (!inherits(gini, "try-error")) head(gini) options(op)op <- options(readoecd.cache_dir = tempdir()) gini <- try(get_oecd_inequality(c("AUS", "GBR", "USA", "DNK"), start_year = 2000)) if (!inherits(gini, "try-error")) head(gini) options(op)
Downloads (and caches) labour productivity data for OECD member countries from the OECD Productivity Database (PDB).
get_oecd_productivity(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_productivity(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
Returns GDP per hour worked where available (in USD purchasing power parities), falling back to GDP per capita. Values are at current prices.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"GDP_PER_HOUR" or "GDP_PER_CAPITA" (character)
Productivity value (numeric)
Unit of measurement (character)
Other productivity and trade:
get_oecd_current_account()
op <- options(readoecd.cache_dir = tempdir()) prod <- try(get_oecd_productivity(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(prod, "try-error")) head(prod) options(op)op <- options(readoecd.cache_dir = tempdir()) prod <- try(get_oecd_productivity(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(prod, "try-error")) head(prod) options(op)
Downloads (and caches) total tax revenue as a share of GDP for OECD member countries from the OECD Revenue Statistics Comparator database.
get_oecd_tax(countries = "all", start_year = 1990, refresh = FALSE)get_oecd_tax(countries = "all", start_year = 1990, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar year (integer)
"TAX_REVENUE" (character)
Total tax revenue as a share of GDP (numeric)
"% of GDP" (character)
Other fiscal:
get_oecd_deficit()
op <- options(readoecd.cache_dir = tempdir()) tax <- try(get_oecd_tax(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(tax, "try-error")) head(tax) options(op)op <- options(readoecd.cache_dir = tempdir()) tax <- try(get_oecd_tax(c("AUS", "GBR", "USA"), start_year = 2000)) if (!inherits(tax, "try-error")) head(tax) options(op)
Downloads (and caches) monthly harmonised unemployment rates for OECD member countries from the OECD Labour Force Statistics database.
get_oecd_unemployment(countries = "all", start_year = 2000, refresh = FALSE)get_oecd_unemployment(countries = "all", start_year = 2000, refresh = FALSE)
countries |
Character vector of ISO 3166-1 alpha-3 country codes, or
|
start_year |
Numeric. Earliest year to include. Defaults to |
refresh |
Logical. If |
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.
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Calendar month in "YYYY-MM" format (character)
"Unemployment rate" (character)
Unemployment rate as a percentage of the labour force (numeric)
"% of labour force" (character)
Other economic indicators:
get_oecd_cpi(),
get_oecd_gdp()
op <- options(readoecd.cache_dir = tempdir()) # All OECD members since 2010 une <- try(get_oecd_unemployment(start_year = 2010)) # Australia and UK since 2020 une <- try(get_oecd_unemployment(c("AUS", "GBR"), start_year = 2020)) if (!inherits(une, "try-error")) { # 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) } options(op)op <- options(readoecd.cache_dir = tempdir()) # All OECD members since 2010 une <- try(get_oecd_unemployment(start_year = 2010)) # Australia and UK since 2020 une <- try(get_oecd_unemployment(c("AUS", "GBR"), start_year = 2020)) if (!inherits(une, "try-error")) { # 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) } options(op)
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.
list_oecd_countries()list_oecd_countries()
A data frame with columns:
ISO 3166-1 alpha-3 country code (character)
English country name (character)
Other utilities:
check_oecd_api(),
clear_oecd_cache()
list_oecd_countries()list_oecd_countries()