postSoviet <- c("AM", "AZ", "BY", "MD", "GE", "KG", "KZ", "RU", "TJ", "TM", "UA", "UZ")
codes <- search_eurostat(pattern = "EU direct investment flows, breakdown by partner country")
codes$code
## [1] "bop_fdi_flow_r2" "bop_fdi_flows" "bop_fdi6_flow"
bop_fdi_flows <- get_eurostat("bop_fdi_flows", time_format = "num")
## Table bop_fdi_flows cached at /tmp/RtmpXUMifS/eurostat/bop_fdi_flows_num_code_TF.rds
bop_fdi_flow_r2 <- get_eurostat("bop_fdi_flow_r2", time_format = "num")
## Table bop_fdi_flow_r2 cached at /tmp/RtmpXUMifS/eurostat/bop_fdi_flow_r2_num_code_TF.rds
bop_fdi6_flow <- get_eurostat("bop_fdi6_flow", time_format = "num")
## Table bop_fdi6_flow cached at /tmp/RtmpXUMifS/eurostat/bop_fdi6_flow_num_code_TF.rds
fdi <- bind_rows(bop_fdi_flows, bop_fdi_flow_r2, bop_fdi6_flow)
## Warning in bind_rows_(x, .id): Unequal factor levels: coercing to character
## Warning in bind_rows_(x, .id): Unequal factor levels: coercing to character
## Warning in bind_rows_(x, .id): Unequal factor levels: coercing to character
## Warning in bind_rows_(x, .id): Unequal factor levels: coercing to character
## Keep only post-Soviet countries
fdiPS <- fdi[grepl(paste(postSoviet, collapse = "|"), x = fdi$partner)&nchar(as.character(fdi$partner))==2&fdi$time>2000,]
## Plot the data
fdiPS %>% group_by(partner, time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values, color = partner)) + geom_line() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title = "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics", caption = "Eurostat indicator: bop_fdi_flows")
Same as above, but without Russia.
fdiPS %>% filter(partner!="RU") %>% group_by(partner, time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values, color = partner)) + geom_line() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics and Russia", caption = "Eurostat indicator: bop_fdi_flows")
Click on “RU” to hide it and increase visibility of others
fdiPS %>% group_by(partner, time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% hchart("line", x = time, y = values, group = partner)
fdiPS %>% group_by(time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values)) + geom_line() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics", caption = "Eurostat indicator: bop_fdi_flows")
fdiPS %>% filter(partner!="RU") %>% group_by(time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values)) + geom_line() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics and Russia", caption = "Eurostat indicator: bop_fdi_flows")
Same as above, but alternative visualization with barcharts
fdiPS %>% group_by(time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values)) + geom_col() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics", caption = "Eurostat indicator: bop_fdi_flows")
fdiPS %>% filter(partner!="RU") %>% group_by(time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values)) + geom_col() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics and Russia", caption = "Eurostat indicator: bop_fdi_flows")
fdiPS %>% filter(partner!="RU") %>% group_by(time) %>% summarise(values = sum(values, na.rm = TRUE)) %>% ggplot(mapping = aes(x = time, y = values)) + geom_col() + scale_x_continuous(breaks=unique(fdiPS$time), name = "") + scale_y_continuous(labels = comma, name = "") + labs(title= "EU direct investment flowss, by partner country ", subtitle = "Post-Soviet only, excluding Baltic republics and Russia", caption = "Eurostat indicator: bop_fdi_flows")