~/data/oecd/

Info

source dataset .html .RData
oecd api 2024-04-16 2024-04-16

List of APIs

source dataset .html .RData
bdf api 2024-04-18 NA
bea api 2024-02-11 NA
bis api 2024-04-19 NA
bls api 2024-02-11 NA
ecb api 2024-04-19 NA
eurostat api 2024-04-18 NA
imf api 2024-02-11 NA
insee api 2024-04-30 NA
oecd api 2024-04-16 2024-04-16
rdb api 2024-04-25 NA
wdi api 2024-04-14 NA

LAST_COMPILE

LAST_COMPILE
2024-05-07

Info

GDP Per capita, US vs. EU

Data

QNA_EXPENDITURE_CAPITA <- "https://sdmx.oecd.org/public/rest/data/OECD.SDD.NAD,DSD_NAMAIN1@DF_QNA_EXPENDITURE_CAPITA,1.0/Q..USA+EA20........LR.." %>%
  readSDMX() %>%
  as_tibble

Metadata

Download

QNA_EXPENDITURE_CAPITA_var <- "https://sdmx.oecd.org/public/rest/dataflow/OECD.SDD.NAD/DSD_NAMAIN1@DF_QNA_EXPENDITURE_CAPITA/1.0?references=all" %>%
  readSDMX()

English

metadata_load <- function(code, CL_code, data = QNA_EXPENDITURE_CAPITA_var){
  assign(code, as.data.frame(data@codelists, codelistId = CL_code) %>%
           select(id, label.en) %>%
           setNames(c(code, str_to_title(code))),
         envir = .GlobalEnv)
}
metadata_load("REF_AREA", "CL_AREA")
REF_AREA %>%
  print_table_conditional()

French

metadata_load_fr <- function(code, CL_code, data = QNA_EXPENDITURE_CAPITA_var){
  assign(code, as.data.frame(data@codelists, codelistId = CL_code) %>%
           select(id, label.fr) %>%
           setNames(c(code, str_to_title(code))),
         envir = .GlobalEnv)
}
metadata_load_fr("REF_AREA", "CL_AREA")
REF_AREA %>%
  print_table_conditional()

Plot

QNA_EXPENDITURE_CAPITA %>%
  filter(REF_AREA %in% c("USA", "EA20"),
         FREQ == "Q",
         PRICE_BASE == "LR") %>%
  quarter_to_date %>%
  filter(date >= as.Date("1999-01-01")) %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("PIB par habitant (1999T1 = 100)") +
  geom_line(aes(x = date, y = obsValue, color = Ref_area)) + 
  scale_color_manual(values = c("#B22234", "#003399")) +
  geom_rect(data = nber_recessions %>%
              filter(Peak > as.Date("1999-01-01")), 
            aes(xmin = Peak, xmax = Trough, ymin = 0, ymax = +Inf), 
            fill = '#B22234', alpha = 0.1)  +
  geom_rect(data = cepr_recessions %>%
              filter(Peak > as.Date("1999-01-01")), 
            aes(xmin = Peak, xmax = Trough, ymin = 0, ymax = +Inf), 
            fill = '#003399', alpha = 0.1)  +
  scale_x_date(breaks = c(seq(1999, 2100, 5), seq(1997, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.26, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = seq(50, 200, 5))