Project Part 2

Interactive and static plots of military expenditure from 1949 to 2020.

1- Packages, I will use to read in and plot the data.

2- Read the data in from part 1.

regional_military_spending <- read.csv(here::here("regional_military_spending.csv"))

Interactive graph.

regional_military_spending %>% 
  group_by(Region) %>% 
  mutate(Year = paste(Year, "12", "31", sep = "-")) %>% 
  e_charts(x= Year) %>%
  e_river( serie = military_spending, legend = FALSE) %>% 
  e_tooltip(trigger = "axis") %>% 
  e_title(text = "Annual military spending, by world region",
          subtext = "(in billions of dollars). Source: Our World in Data", 
          sublink = "https://ourworldindata.org/grapher/military-expenditure-total?tab=chart",
          left= " center") %>% 
  e_theme("roma")

static graph

regional_military_spending %>% 
  ggplot(aes(x = Year, y = military_spending, 
             fill = Region)) +
  geom_area() + 
  colorspace:: scale_fill_discrete_divergingx(palette = "roma", nmax = 8) +
  theme_classic() + 
  theme(legend.position = "bottom") +
  labs(y = "in billions of dollars", fill= NULL)

These plots show a non steady movement in military spending since 1949. It may be explained by the correlation between world geopolitical or peace environment and military spending.

ggsave(filename = here:: here("_posts/2022-05-11-project-part-2/preview.png"))