Quarterly GDP and components - expenditure approach

Data - OECD

Info

source dataset Title .html .rData
oecd QNA_EXPENDITURE_CAPITA Quarterly National Accounts, GDP Per Capita 2026-02-22 2026-03-11
oecd QNA_EXPENDITURE_NATIO_CURR Quarterly GDP and components - expenditure approach 2026-02-22 2026-03-11

Last

obsTime Nobs
2025-Q4 3235

PRICE_BASE

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  left_join(PRICE_BASE, by = "PRICE_BASE") %>%
  group_by(PRICE_BASE, Price_base) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
PRICE_BASE Price_base Nobs
V Current prices 357419
L Chain linked volume 275146
Q Constant prices 19919

REF_AREA

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  group_by(REF_AREA, Ref_area) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()

TRANSACTION

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  left_join(TRANSACTION, by = "TRANSACTION") %>%
  group_by(TRANSACTION, Transaction) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
TRANSACTION Transaction Nobs
P3 Final consumption expenditure 151047
P51G Gross fixed capital formation 41194
B1GQ Gross domestic product 34198
P6 Exports of goods and services 33928
P7 Imports of goods and services 33928
B11 External balance of goods and services 33495
P5 Gross capital formation 31526
P61 Exports of goods 30103
P62 Exports of services 30103
P71 Imports of goods 30103
P72 Imports of services 30103
P3T5 Domestic demand 23549
P31 Individual consumption expenditure 21740
P32 Collective consumption expenditure 21740
P5M Changes in inventories and acquisitions less disposals of valuables 21017
P41 Actual individual consumption 20815
P52 Changes in inventories 20118
YA0 Statistical discrepancy (expenditure approach) 13637
PPP_B1GQ Purchasing Power Parities for GDP 12673
P53 Acquisitions less disposals of valuables 12037
P3_P51G Final domestic demand excluding inventories 3581
P3T6 Total demand 1849

ACTIVITY

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  left_join(ACTIVITY, by = "ACTIVITY") %>%
  group_by(ACTIVITY, Activity) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
ACTIVITY Activity Nobs
_Z Not applicable 526592
_T Total - all activities 125892

U.S. VS Europe

Table

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20"),
         FREQ == "Q",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1",
         obsTime %in% c("1999-Q1", "2023-Q4")) %>%
  left_join(TRANSACTION, by = "TRANSACTION") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = 4*obsValue/population) %>%
  select_if(~ n_distinct(.) > 1) %>%
  select(REF_AREA, TRANSACTION, Transaction, obsTime, obsValue) %>%
  spread(obsTime, obsValue) %>%
  mutate(change = `2023-Q4`-`1999-Q1`) %>%
  select(REF_AREA, TRANSACTION, Transaction, change) %>%
  spread(REF_AREA, change) %>%
  print_table_conditional()
TRANSACTION Transaction EA20 USA
B11 External balance of goods and services 1.521722 -1.7562333
B1GQ Gross domestic product 8.160956 20.2089680
P3 Final consumption expenditure 5.304127 16.9323870
P3_P51G Final domestic demand excluding inventories NA 21.9965672
P3T5 Domestic demand NA 21.9885562
P5 Gross capital formation 1.291135 5.1699033
P51G Gross fixed capital formation 1.708753 5.1380607
P52 Changes in inventories NA -0.2244694
P5M Changes in inventories and acquisitions less disposals of valuables NA -0.2244694
P6 Exports of goods and services 9.982813 3.3483935
P61 Exports of goods 6.177514 2.2416424
P62 Exports of services 3.856901 1.1334371
P7 Imports of goods and services 8.461091 5.1046312
P71 Imports of goods 5.052489 4.1602559
P72 Imports of services 3.559141 0.9461343
YA0 Statistical discrepancy (expenditure approach) NA -0.2418460

P3 - Final consumption expenditure / capita

Code
metadata_load_fr("REF_AREA", "CL_AREA", data = QNA_EXPENDITURE_NATIO_CURR_var)
plot <- QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20"),
         FREQ == "Q",
         TRANSACTION == "P3",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Zone euro", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("Consommation par habitant (1999T1 = 100)") +
  geom_line(aes(x = date, y = obsValue, color = Ref_area)) +
  scale_color_manual(values = c("#B22234", "#003399")) +
  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)) +
  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) +
  labs(caption = "Source: OCDE, Comptes Trimestriels, Volumes chaînés")

plot

Code
save(plot, file = "QNA_EXPENDITURE_NATIO_CURR_files/figure-html/USA-EA20-1999-percapita-1.RData")

U.S., Europe, France, Germany

B1GQ - GDP

1995-

Code
metadata_load("REF_AREA", "CL_AREA", data = QNA_EXPENDITURE_NATIO_CURR_var)
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "B1GQ",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  arrange(desc(date)) %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1995-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  scale_x_date(breaks = c(seq(1995, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

1999-

Total

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "B1GQ",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

Per Capita

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "B1GQ",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

P51G - Gross fixed capital formation

1995-

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P51G",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  arrange(desc(date)) %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1995-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  scale_x_date(breaks = c(seq(1995, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = "none") +
  scale_y_log10(breaks = seq(50, 500, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

1999-

Total

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P51G",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

Per Capita

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P51G",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

P3 - Final consumption expenditure

All

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P3",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  arrange(desc(date)) %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  scale_x_date(breaks = c(seq(1900, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = "none") +
  scale_y_log10(breaks = seq(20, 600, 20))

1995-

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P3",
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  arrange(desc(date)) %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1995-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  scale_x_date(breaks = c(seq(1995, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

1999-

Total

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P3",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_4flags +
  scale_color_identity() +
  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)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

Per Capita

Code
metadata_load_fr("REF_AREA", "CL_AREA", data = QNA_EXPENDITURE_NATIO_CURR_var)
plot <- QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P3",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y",
         SECTOR == "S1") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Zone euro", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("Consommation par habitant (1999T1 = 100)") +
  geom_line(aes(x = date, y = obsValue, color = Ref_area)) +
  scale_color_manual(values = c("#000000", "#B22234", "#808080", "#003399")) +
  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))  +
  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)  +
  labs(caption = "Source: OCDE, Comptes Trimestriels, Volumes chaînés")


save(plot, file = "QNA_EXPENDITURE_NATIO_CURR_files/figure-html/USA-EA20-FRA-DEU-1999-percapita-1.RData")

plot

P31 - Individual consumption expenditure

Code
metadata_load("REF_AREA", "CL_AREA", data = QNA_EXPENDITURE_NATIO_CURR_var)
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P31",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_3flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

P32 - Collective consumption expenditure

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P32",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_3flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

P41 - Actual individual consumption

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P41",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_2flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

P3T5 - Domestic demand

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA", "EA20", "FRA", "DEU"),
         FREQ == "Q",
         TRANSACTION == "P3T5",
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y") %>%
  left_join(QNA_POP_EMPNC_extract, by = c("obsTime", "REF_AREA")) %>%
  mutate(obsValue = obsValue/population) %>%
  quarter_to_date %>%
  
  left_join(REF_AREA, by = "REF_AREA") %>%
  filter(date >= as.Date("1999-01-01")) %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  arrange(date) %>%
  mutate(obsValue = 100 * obsValue / obsValue[1]) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(Ref_area != "DEU", color2, color)) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) + add_3flags +
  scale_color_identity() +
  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 = "none") +
  scale_y_log10(breaks = seq(50, 200, 5)) + 
  geom_label_repel(data = . %>% filter(date == max(date)),
             aes(x = date, y = obsValue, label = round(obsValue, 1), color = color))

Net exports

Eurozone, US, France, Germany

Tous

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20", "USA", "DEU", "FRA"),
         FREQ == "Q",
         TRANSACTION %in% c("B11", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  select_if(~ n_distinct(.) > 1) %>%
  select(-OBS_STATUS) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  filter(date >= as.Date("1970-01-01")) %>%
  transmute(date, Ref_area, obsValue = B11/B1GQ) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  ggplot + geom_line(aes(x = date, y = obsValue, color = color)) +
  theme_minimal() + xlab("") + ylab("") + scale_color_identity() + add_4flags +
  scale_x_date(breaks = c(seq(1970, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 1),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank()) +
  geom_hline(yintercept = 0, linetype = "dashed")

1990-

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20", "USA", "DEU", "FRA"),
         FREQ == "Q",
         TRANSACTION %in% c("B11", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  left_join(PRICE_BASE, by = "PRICE_BASE") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  select_if(~ n_distinct(.) > 1) %>%
  select(-OBS_STATUS) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  filter(date >= as.Date("1990-01-01")) %>%
  transmute(date, Ref_area, obsValue = B11/B1GQ) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  ggplot + geom_line(aes(x = date, y = obsValue, color = color)) +
  theme_minimal() + xlab("") + ylab("") + scale_color_identity() + add_4flags +
  scale_x_date(breaks = c(seq(1970, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 1),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank()) +
  geom_hline(yintercept = 0, linetype = "dashed")

Eurozone, US

Tous

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20", "USA"),
         FREQ == "Q",
         TRANSACTION %in% c("B11", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  transmute(date, REF_AREA, Ref_area, obsValue = B11/B1GQ) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(REF_AREA == "USA", color2, color)) %>%
  ggplot + geom_line(aes(x = date, y = obsValue, color = color)) +
  theme_minimal() + xlab("") + ylab("") + scale_color_identity() + add_2flags +
  scale_x_date(breaks = c(seq(1920, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 1),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank()) +
  geom_hline(yintercept = 0, linetype = "dashed")

1970-

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20", "USA"),
         FREQ == "Q",
         TRANSACTION %in% c("B11", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  filter(date >= as.Date("1970-01-01")) %>%
  transmute(date, REF_AREA, Ref_area, obsValue = B11/B1GQ) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(REF_AREA == "USA", color2, color)) %>%
  ggplot + geom_line(aes(x = date, y = obsValue, color = color)) +
  theme_minimal() + xlab("") + ylab("") + scale_color_identity() + add_2flags +
  scale_x_date(breaks = c(seq(1970, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 1),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank()) +
  geom_hline(yintercept = 0, linetype = "dashed")

1990-

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20", "USA"),
         FREQ == "Q",
         TRANSACTION %in% c("B11", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  left_join(REF_AREA, by = "REF_AREA") %>%
  mutate(Ref_area = ifelse(REF_AREA == "EA20", "Europe", Ref_area)) %>%
  group_by(Ref_area) %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  filter(date >= as.Date("1995-01-01")) %>%
  transmute(date, REF_AREA, Ref_area, obsValue = B11/B1GQ) %>%
  left_join(colors, by = c("Ref_area" = "country")) %>%
  mutate(color = ifelse(REF_AREA == "USA", color2, color)) %>%
  ggplot + geom_line(aes(x = date, y = obsValue, color = color)) +
  theme_minimal() + xlab("") + ylab("") + scale_color_identity() + add_2flags +
  scale_x_date(breaks = c(seq(1970, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 1),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank()) +
  geom_hline(yintercept = 0, linetype = "dashed")

Exports and Imports as a % of GDP

EA 20

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("EA20"),
         FREQ == "Q",
         TRANSACTION %in% c("P6", "P7", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "L",
         ADJUSTMENT == "Y") %>%
  select_if(~ n_distinct(.) > 1) %>%
  select(-OBS_STATUS) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  transmute(date, `Exports (% of GDP)` = P6/B1GQ, `Imports (% of GDP)` = P7/B1GQ) %>%
  gather(variable, value, -date) %>%
  ggplot + geom_line(aes(x = date, y = value, color = variable)) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = c(seq(1999, 2100, 5), seq(1997, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 5),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank())

USA

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("USA"),
         FREQ == "Q",
         TRANSACTION %in% c("P6", "P7", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  transmute(date, `Exports (% of GDP)` = P6/B1GQ, `Imports (% of GDP)` = P7/B1GQ) %>%
  gather(variable, value, -date) %>%
  ggplot + geom_line(aes(x = date, y = value, color = variable)) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = c(seq(1940, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 2),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank())

Germany

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("DEU"),
         FREQ == "Q",
         TRANSACTION %in% c("P6", "P7", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  transmute(date, `Exports (% of GDP)` = P6/B1GQ, `Imports (% of GDP)` = P7/B1GQ) %>%
  gather(variable, value, -date) %>%
  ggplot + geom_line(aes(x = date, y = value, color = variable)) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = c(seq(1940, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 2),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank())

France

Code
QNA_EXPENDITURE_NATIO_CURR %>%
  filter(REF_AREA %in% c("FRA"),
         FREQ == "Q",
         TRANSACTION %in% c("P6", "P7", "B1GQ"),
         # L = Chain linked volume
         PRICE_BASE == "V",
         ADJUSTMENT == "Y") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(TRANSACTION, obsValue) %>%
  quarter_to_date() %>%
  transmute(date, `Exports (% of GDP)` = P6/B1GQ, `Imports (% of GDP)` = P7/B1GQ) %>%
  gather(variable, value, -date) %>%
  ggplot + geom_line(aes(x = date, y = value, color = variable)) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = c(seq(1940, 2100, 5)) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-100, 100, 2),
                labels = percent_format(acc = 1)) +
  theme(legend.position = c(0.2, 0.8),
        legend.title = element_blank())