API: OECD

Access OECD countries and selected non-member economies data through the OECD API.

Table of Contents


By using SKEMA Quantum Studio framework (Warin 2019), this course will teach you how to use the OECD package.

Database description

The Organisation for Economic Co-operation and Development (OECD) is an intergovernmental economic organisation with 36 member countries. It is a forum of countries providing a platform to compare policy experiences, seek answers to common problems, identify good practices and coordinate domestic and international policies of its members.

OECD : https://www.oecd.org/about/

Functions

Each of these functions are detailed in this course and some examples are provided.

search_dataset()

The function search_dataset() searches for OECD indicators. It takes as an input the indicator that would be useful for your analysis. It searches and returns a table of all the available indicator related to the input inserted.


# Loading OECD library
library(OECD)

# List all available datasets
dataset_list <- get_datasets()

# Search all indicators with the term "unemployment"
search_dataset("unemployment", data = dataset_list)

# A tibble: 7 x 2
  id              title                                               
  <fct>           <fct>                                               
1 DUR_I           Incidence of unemployment by duration               
2 DUR_D           Unemployment by duration                            
3 AVD_DUR         Average duration of unemployment                    
4 AEO2012_CH6_FI… Figure 4: Youth and adult unemployment              
5 AEO2012_CH6_FI… Figure 29: Youth employment and unemployment by edu…
6 AEO2012_CH6_FI… Figure 19: The trade off between vulnerable employm…
7 NRR             Net Replacement Rates in unemployment               

get_data_structure()

The function get_data_structure takes as an input the id associate with the dataset and returns the structure of any query made with the OECD package.


# Structure of a query
dstruc <- get_data_structure("DUR_D")
str(dstruc, max.level = 1)

List of 12
 $ VAR_DESC       :'data.frame':    12 obs. of  2 variables:
 $ COUNTRY        :'data.frame':    53 obs. of  2 variables:
 $ TIME           :'data.frame':    51 obs. of  2 variables:
 $ SEX            :'data.frame':    3 obs. of  2 variables:
 $ AGE            :'data.frame':    7 obs. of  2 variables:
 $ DURATION       :'data.frame':    8 obs. of  2 variables:
 $ FREQUENCY      :'data.frame':    1 obs. of  2 variables:
 $ OBS_STATUS     :'data.frame':    15 obs. of  2 variables:
 $ UNIT           :'data.frame':    316 obs. of  2 variables:
 $ POWERCODE      :'data.frame':    32 obs. of  2 variables:
 $ REFERENCEPERIOD:'data.frame':    92 obs. of  2 variables:
 $ TIME_FORMAT    :'data.frame':    5 obs. of  2 variables:

get_datasets()

The function get_datasets takes as an input the dataset id and filters. Add a variable to list all of the specific filters allows to simplify the input of the function. get_datasets returns a dataframe containing the selected data.


# Filter use to narrow the research (Canada-Germany-France-USA; male and female; 20-24 years old)
filter_list <- list(c("DEU", "FRA", "CAN", "USA"), "MW", "2024")

# Dataframe containing selected data
unemployementOECD <- get_dataset(dataset = "DUR_D", filter = filter_list)
unemployementOECD[1:6,]

# A tibble: 6 x 8
  COUNTRY SEX   AGE   DURATION FREQUENCY TIME_FORMAT obsTime obsValue
  <chr>   <chr> <chr> <chr>    <chr>     <chr>       <chr>      <dbl>
1 FRA     MW    2024  UN1      A         P1Y         1975        31.0
2 FRA     MW    2024  UN1      A         P1Y         1976        27.2
3 FRA     MW    2024  UN1      A         P1Y         1977        29.2
4 FRA     MW    2024  UN1      A         P1Y         1978        26.5
5 FRA     MW    2024  UN1      A         P1Y         1979        32.0
6 FRA     MW    2024  UN1      A         P1Y         1980        31.9

tl;dr


# Loading OECD library
library(OECD)

# List all available datasets
dataset_list <- get_datasets()

# Search all indicators with the term "unemployment"
search_dataset("unemployment", data = dataset_list)

# A tibble: 7 x 2
  id              title                                               
  <fct>           <fct>                                               
1 DUR_I           Incidence of unemployment by duration               
2 DUR_D           Unemployment by duration                            
3 AVD_DUR         Average duration of unemployment                    
4 AEO2012_CH6_FI… Figure 4: Youth and adult unemployment              
5 AEO2012_CH6_FI… Figure 29: Youth employment and unemployment by edu…
6 AEO2012_CH6_FI… Figure 19: The trade off between vulnerable employm…
7 NRR             Net Replacement Rates in unemployment               

# Structure of a query
dstruc <- get_data_structure("DUR_D")
str(dstruc, max.level = 1)

List of 12
 $ VAR_DESC       :'data.frame':    12 obs. of  2 variables:
 $ COUNTRY        :'data.frame':    53 obs. of  2 variables:
 $ TIME           :'data.frame':    51 obs. of  2 variables:
 $ SEX            :'data.frame':    3 obs. of  2 variables:
 $ AGE            :'data.frame':    7 obs. of  2 variables:
 $ DURATION       :'data.frame':    8 obs. of  2 variables:
 $ FREQUENCY      :'data.frame':    1 obs. of  2 variables:
 $ OBS_STATUS     :'data.frame':    15 obs. of  2 variables:
 $ UNIT           :'data.frame':    316 obs. of  2 variables:
 $ POWERCODE      :'data.frame':    32 obs. of  2 variables:
 $ REFERENCEPERIOD:'data.frame':    92 obs. of  2 variables:
 $ TIME_FORMAT    :'data.frame':    5 obs. of  2 variables:

# Filter use to narrow the research (Canada-Germany-France-USA; male and female; 20-24 years old)
filter_list <- list(c("DEU", "FRA", "CAN", "USA"), "MW", "2024")

# Dataframe containing selected data
unemployementOECD <- get_dataset(dataset = "DUR_D", filter = filter_list)
unemployementOECD[1:6,]

# A tibble: 6 x 8
  COUNTRY SEX   AGE   DURATION FREQUENCY TIME_FORMAT obsTime obsValue
  <chr>   <chr> <chr> <chr>    <chr>     <chr>       <chr>      <dbl>
1 FRA     MW    2024  UN1      A         P1Y         1975        31.0
2 FRA     MW    2024  UN1      A         P1Y         1976        27.2
3 FRA     MW    2024  UN1      A         P1Y         1977        29.2
4 FRA     MW    2024  UN1      A         P1Y         1978        26.5
5 FRA     MW    2024  UN1      A         P1Y         1979        32.0
6 FRA     MW    2024  UN1      A         P1Y         1980        31.9

Code learned this week

Command Detail
search_dataset() Search for OECD indicators
get_data_structure() Read the structure of any query made with the OECD package
get_datasets() Find data related to the indicators

References

This course uses the OECD package documentation


Warin, Thierry. 2019. “SKEMA Quantum Studio: A Technological Framework for Data Science in Higher Education.” https://doi.org/10.6084/m9.figshare.8204195.v2.

Citation

For attribution, please cite this work as

Warin (2020, Jan. 27). Virtual Campus: API: OECD. Retrieved from https://virtualcampus.skemagloballab.io/posts/apioecd/

BibTeX citation

@misc{warin2020api:,
  author = {Warin, Thierry},
  title = {Virtual Campus: API: OECD},
  url = {https://virtualcampus.skemagloballab.io/posts/apioecd/},
  year = {2020}
}