Gross domestic product (GDP), SNA93 - SNA_TABLE1_SNA93

Data - OECD

Code
load_data("oecd/SNA_TABLE1_SNA93_var.RData")
load_data("oecd/SNA_TABLE1_SNA93.RData")
load_data("us/nber_recessions.RData")

Layout - By country

  • OECD Website. html

United States

Nobs - Javascript

Code
SNA_TABLE1_SNA93 %>%
  left_join(SNA_TABLE1_SNA93_var %>% pluck("TRANSACT"), by = c("TRANSACT" = "id")) %>%
  rename(`TRANSACT Description` = label) %>%
  left_join(SNA_TABLE1_SNA93_var %>% pluck("MEASURE"), by = c("MEASURE" = "id")) %>%
  rename(`MEASURE Description` = label) %>%
  group_by(TRANSACT, `TRANSACT Description`, MEASURE, `MEASURE Description`) %>%
  summarise(nobs = n()) %>%
  arrange(-nobs) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Data Structure

Code
SNA_TABLE1_SNA93_var$VAR_DESC %>%
  {if (is_html_output()) print_table(.) else .}
id description
LOCATION Country
TRANSACT Transaction
MEASURE Measure
TIME Year
OBS_VALUE Observation Value
TIME_FORMAT Time Format
OBS_STATUS Observation Status
UNIT Unit
POWERCODE Unit multiplier
REFERENCEPERIOD Reference period

TRANSACT

Code
SNA_TABLE1_SNA93 %>%
  left_join(SNA_TABLE1_SNA93_var$TRANSACT, by = c("TRANSACT" = "id")) %>%
  rename(`TRANSACT Description` = label) %>%
  group_by(TRANSACT, `TRANSACT Description`) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

MEASURE

Code
SNA_TABLE1_SNA93 %>%
  left_join(SNA_TABLE1_SNA93_var$MEASURE, by = c("MEASURE" = "id")) %>%
  rename(`MEASURE Description` = label) %>%
  group_by(MEASURE, `MEASURE Description`) %>%
  summarise(Nobs = n()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

How much data

Code
SNA_TABLE1_SNA93 %>%
  filter(TRANSACT == "B1_GE",
         MEASURE == "C") %>%
  left_join(SNA_TABLE1_SNA93_var$LOCATION %>%
              setNames(c("LOCATION", "LOCATION_desc")), 
            by = "LOCATION") %>%
  group_by(LOCATION, UNIT, LOCATION_desc) %>%
  summarise(year_first = first(obsTime),
            year_last = last(obsTime),
            value_last = last(round(obsValue))) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Ex: B1_GA - Gross domestic product (output approach)

Code
SNA_TABLE1_SNA93 %>%
  filter(LOCATION %in% c("USA"),
         TRANSACT == "B1_GA",
         MEASURE %in% c("C", "V")) %>%
  mutate(date = paste0(obsTime, "-01-01") %>% as.Date,
         obsValue = obsValue / 10^6) %>%
  left_join(SNA_TABLE1_SNA93_var$LOCATION %>%
              rename(LOCATION = id),
            by = "LOCATION") %>%
  left_join(SNA_TABLE1_SNA93_var$MEASURE %>%
              rename(MEASURE = id, MEASURE_label = label),
            by = "MEASURE") %>%
  group_by(LOCATION) %>%
  arrange(date) %>%
  select(date, obsValue, MEASURE_label) %>%
  ggplot(.) + geom_line(aes(x = date, y = obsValue, linetype = MEASURE_label, color = MEASURE_label)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_color_manual(values = viridis(4)[1:3]) +
  geom_rect(data = nber_recessions, 
            aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf), 
            fill = 'grey', alpha = 0.5) +
  scale_x_date(breaks = seq(1960, 2020, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%y"),
               limits = c(1970, 2019) %>% paste0("-01-01") %>% as.Date) +
  scale_y_continuous(breaks = seq(0, 30, 1),
                     labels = dollar_format(suffix = "Tn", prefix = "$", accuracy = 1)) +
  theme(legend.position = c(0.3, 0.90),
        legend.title = element_blank())

Ex: P3 - Final consumption expenditure

Code
SNA_TABLE1_SNA93 %>%
  filter(LOCATION %in% c("USA"),
         TRANSACT == "P3",
         MEASURE %in% c("C", "V")) %>%
  mutate(date = paste0(obsTime, "-01-01") %>% as.Date,
         obsValue = obsValue / 10^6) %>%
  left_join(SNA_TABLE1_SNA93_var$LOCATION %>%
              rename(LOCATION = id),
            by = "LOCATION") %>%
  left_join(SNA_TABLE1_SNA93_var$MEASURE %>%
              rename(MEASURE = id, MEASURE_label = label),
            by = "MEASURE") %>%
  group_by(LOCATION) %>%
  arrange(date) %>%
  select(date, obsValue, MEASURE_label) %>%
  ggplot(.) + geom_line(aes(x = date, y = obsValue, linetype = MEASURE_label, color = MEASURE_label)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_color_manual(values = viridis(4)[1:3]) +
  geom_rect(data = nber_recessions, 
            aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf), 
            fill = 'grey', alpha = 0.5) +
  scale_x_date(breaks = seq(1960, 2020, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%y"),
               limits = c(1970, 2019) %>% paste0("-01-01") %>% as.Date) +
  scale_y_continuous(breaks = seq(0, 30, 1),
                     labels = dollar_format(suffix = "Tn", prefix = "$", accuracy = 1)) +
  theme(legend.position = c(0.3, 0.90),
        legend.title = element_blank())

Ex: P51 - Investment

Code
SNA_TABLE1_SNA93 %>%
  filter(LOCATION %in% c("USA"),
         TRANSACT == "P51",
         MEASURE %in% c("C", "V")) %>%
  mutate(date = paste0(obsTime, "-01-01") %>% as.Date,
         obsValue = obsValue / 10^6) %>%
  left_join(SNA_TABLE1_SNA93_var$LOCATION %>%
              rename(LOCATION = id),
            by = "LOCATION") %>%
  left_join(SNA_TABLE1_SNA93_var$MEASURE %>%
              rename(MEASURE = id, MEASURE_label = label),
            by = "MEASURE") %>%
  group_by(LOCATION) %>%
  arrange(date) %>%
  select(date, obsValue, MEASURE_label) %>%
  ggplot(.) + geom_line(aes(x = date, y = obsValue, linetype = MEASURE_label, color = MEASURE_label)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_color_manual(values = viridis(4)[1:3]) +
  geom_rect(data = nber_recessions, 
            aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf), 
            fill = 'grey', alpha = 0.5) +
  scale_x_date(breaks = seq(1960, 2020, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%y"),
               limits = c(1970, 2019) %>% paste0("-01-01") %>% as.Date) +
  scale_y_continuous(breaks = seq(0, 10, 0.5),
                     labels = dollar_format(suffix = "Tn", prefix = "$", accuracy = 0.1)) +
  theme(legend.position = c(0.3, 0.90),
        legend.title = element_blank())

Ex: Japan

Code
SNA_TABLE1_SNA93 %>%
  filter(LOCATION %in% c("JPN"),
         TRANSACT == "B1_GE",
         MEASURE %in% c("C", "V")) %>%
  mutate(date = paste0(obsTime, "-01-01") %>% as.Date) %>%
  left_join(SNA_TABLE1_SNA93_var$LOCATION %>%
              rename(LOCATION = id),
            by = "LOCATION") %>%
  left_join(SNA_TABLE1_SNA93_var$MEASURE %>%
              rename(MEASURE = id, MEASURE_label = label),
            by = "MEASURE") %>%
  group_by(LOCATION) %>%
  arrange(date) %>%
  select(date, obsValue, MEASURE_label) %>%
  ggplot(.) + 
  geom_line(aes(x = date, y = obsValue / 10^6, linetype = MEASURE_label, color = MEASURE_label)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_color_manual(values = viridis(4)[1:3]) +
  geom_rect(data = nber_recessions, 
            aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf), 
            fill = 'grey', alpha = 0.5) +
  scale_x_date(breaks = seq(1960, 2020, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%y"),
               limits = c(1970, 2019) %>% paste0("-01-01") %>% as.Date) +
  scale_y_continuous(breaks = seq(0, 600, 50),
                     labels = dollar_format(suffix = " Tn", prefix = "¥", accuracy = 1)) +
  theme(legend.position = c(0.6, 0.20),
        legend.title = element_blank())