Code
tibble(DOWNLOAD_TIME = as.Date(file.info("~/iCloud/website/data/imf/DOT_FR.RData")$mtime)) |>
print_table_conditional()| DOWNLOAD_TIME |
|---|
| NA |
Data - IMF
tibble(DOWNLOAD_TIME = as.Date(file.info("~/iCloud/website/data/imf/DOT_FR.RData")$mtime)) |>
print_table_conditional()| DOWNLOAD_TIME |
|---|
| NA |
DOT_FR |>
group_by(TIME_PERIOD) |>
summarise(Nobs = n()) |>
arrange(desc(TIME_PERIOD)) |>
head(1) |>
print_table_conditional()| TIME_PERIOD | Nobs |
|---|---|
| 2024-Q3 | 672 |
DOT_FR |>
left_join(FREQ, by = "FREQ") |>
group_by(FREQ, Freq) |>
summarise(Nobs = n()) |>
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| FREQ | Freq | Nobs |
|---|---|---|
| M | Monthly | 435855 |
| Q | Quarterly | 149819 |
| A | Annual | 41559 |
DOT_FR |>
left_join(INDICATOR, by = "INDICATOR") |>
group_by(INDICATOR, Indicator) |>
summarise(Nobs = n()) |>
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| INDICATOR | Indicator | Nobs |
|---|---|---|
| TBG_USD | Goods, Value of Trade Balance, US Dollars | 214698 |
| TXG_FOB_USD | Goods, Value of Exports, Free on board (FOB), US Dollars | 211392 |
| TMG_CIF_USD | Goods, Value of Imports, Cost, Insurance, Freight (CIF), US Dollars | 201143 |
DOT_FR |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
group_by(COUNTERPART_AREA, Counterpart_area) |>
summarise(Nobs = n()) |>
arrange(-Nobs) |>
mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Counterpart_area))),
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 .}DOT_FR |>
filter(COUNTERPART_AREA == "DE",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
left_join(INDICATOR, by = "INDICATOR") |>
select(TIME_PERIOD, Indicator, OBS_VALUE) |>
spread(Indicator, OBS_VALUE) |>
arrange(desc(TIME_PERIOD)) |>
print_table_conditional()DOT_FR |>
filter(COUNTERPART_AREA == "DE",
FREQ == "Q") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
left_join(INDICATOR, by = "INDICATOR") |>
select(TIME_PERIOD, Indicator, OBS_VALUE) |>
spread(Indicator, OBS_VALUE) |>
arrange(desc(TIME_PERIOD)) |>
print_table_conditional()DOT_FR |>
left_join(NGDP_USD |>
select(FREQ, REF_AREA, TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = c("TIME_PERIOD", "REF_AREA", "FREQ")) |>
filter(TIME_PERIOD %in% c("2019", "2010", "2000", "1990"),
INDICATOR == "TBG_USD") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
select(COUNTERPART_AREA, Counterpart_area, TIME_PERIOD, OBS_VALUE) |>
spread(TIME_PERIOD, OBS_VALUE) |>
arrange(-`2019`) %>%
mutate_at(vars(-1, -2), funs(round(100*., 2))) |>
mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Counterpart_area))),
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 .}DOT_FR |>
left_join(NGDP_USD |>
select(FREQ, REF_AREA, TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = c("TIME_PERIOD", "REF_AREA", "FREQ")) |>
filter(TIME_PERIOD %in% c("2019", "2010", "2000", "1990"),
INDICATOR == "TBG_USD") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
select(COUNTERPART_AREA, Counterpart_area, TIME_PERIOD, OBS_VALUE) |>
spread(TIME_PERIOD, OBS_VALUE) |>
arrange(-`2019`) %>%
mutate_at(vars(-1, -2), funs(round(100*., 2))) |>
filter(!is.na(`2019`),
`2019` > 0.04) |>
mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Counterpart_area))),
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 .}DOT_FR |>
left_join(NGDP_USD |>
select(FREQ, REF_AREA, TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = c("TIME_PERIOD", "REF_AREA", "FREQ")) |>
filter(TIME_PERIOD %in% c("2019", "2010", "2000", "1990"),
INDICATOR == "TBG_USD") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
select(COUNTERPART_AREA, Counterpart_area, TIME_PERIOD, OBS_VALUE) |>
spread(TIME_PERIOD, OBS_VALUE) |>
arrange(`2019`) %>%
mutate_at(vars(-1, -2), funs(round(100*., 2))) |>
filter(!is.na(`2019`),
`2019` < -0.11) |>
mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Counterpart_area))),
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 .}DOT_FR |>
filter(COUNTERPART_AREA %in% c("GB", "US", "SG"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("QA", "HK", "EG"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "HK", "Hong Kong", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("DE", "NL", "BE"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("DE", "NL", "BE", "W00"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .5),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("DE", "NL", "BE", "W00"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
filter(date >= as.Date("1990-01-01")) |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 5) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .5),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("CN", "IT", "ES"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "ES", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, .1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("CN", "DE", "U2"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, 1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("CN", "DE", "U2"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
filter(date >= as.Date("1980-01-01")) |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, 1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("CN", "DE", "U2"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
filter(date >= as.Date("1990-01-01")) |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, 1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")
DOT_FR |>
filter(COUNTERPART_AREA %in% c("CN", "DE", "U2", "RU"),
INDICATOR %in% c("TBG_USD"),
FREQ == "A") |>
inner_join(NGDP_USD |>
filter(REF_AREA == "FR",
FREQ == "A") |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)) |>
select(TIME_PERIOD, NGDP_USD = OBS_VALUE),
by = "TIME_PERIOD") |>
year_to_date2() |>
mutate(OBS_VALUE = OBS_VALUE*10^(UNIT_MULT)/NGDP_USD) |>
left_join(COUNTERPART_AREA, by = "COUNTERPART_AREA") |>
mutate(Counterpart_area = ifelse(COUNTERPART_AREA == "U2", "Europe", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "W00", "World", Counterpart_area),
Counterpart_area = ifelse(COUNTERPART_AREA == "RU", "Russia", Counterpart_area)) |>
left_join(colors, by = c("Counterpart_area" = "country")) |>
mutate(color = ifelse(COUNTERPART_AREA == "DE", color2, color)) |>
ggplot() + theme_minimal() + scale_color_identity() +
geom_line(aes(x = date, y = OBS_VALUE, color = color)) +
theme(legend.position = "none") + add_flags +
scale_x_date(breaks = seq(1950, 2100, 10) |> paste0("-01-01") |> as.Date(),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-500, 500, 1),
labels = percent_format(accuracy = .1)) +
xlab("") + ylab("France Bilateral Trade Surplus (% of GDP)") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black")