Balance of Payments - bop

Data - GFD

Variables

Code
bop_info %>%
  select(Ticker, Name, Country) %>%
  right_join(bop %>%
               group_by(Ticker) %>%
               summarise(Nobs = n(),
                         start = first(year(date)),
                         end = last(year(date))), by = "Ticker") %>%
  arrange(-Nobs) %>%
  mutate(Flag = gsub(" ", "-", str_to_lower(Country)),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) %>%
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

Metadata

Code
bop_info %>% 
  select(Ticker, Name, Metadata) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

France, United Kingdom

1800-1914

Code
bop %>%
  filter(iso3c %in% c("FRA", "GBR"),
         month(date) == 12,
         date <= as.Date("1914-01-01")) %>%
  select(iso3c, variable, date, value) %>%
  spread(variable, value) %>%
  mutate(NX = BXGUA - BMGUA) %>%
  ggplot() + geom_line(aes(x = date, y = NX, color = iso3c)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1800, 2025, 20) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-2000, 5000, 50),
                labels = dollar_format(suffix = " Bn", accuracy = 1))

1900-1950

Code
bop %>%
  filter(iso3c %in% c("FRA", "GBR", "USA"),
         month(date) == 12,
         date >= as.Date("1900-01-01"),
         date <= as.Date("1950-01-01")) %>%
  select(iso3c, variable, date, value) %>%
  spread(variable, value) %>%
  mutate(NX = BXGUA - BMGUA) %>%
  ggplot() + geom_line(aes(x = date, y = NX, color = iso3c)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1800, 2025, 20) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-2000, 5000, 50),
                labels = dollar_format(suffix = " Bn", accuracy = 1))

United Kingdom, 1800-1914

Code
bop %>%
  filter(iso3c == "GBR",
         month(date) == 12,
         date <= as.Date("1914-01-01")) %>%
  select(variable, date, value) %>%
  spread(variable, value) %>%
  mutate(NX = BXGUA - BMGUA) %>%
  ggplot() + geom_line(aes(x = date, y = NX)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1800, 2025, 20) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.45, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-2000, 5000, 50),
                labels = dollar_format(suffix = " Bn", accuracy = 1))