Project part 2

Interactive and static plots of Air Pollution from 1990 to 2019.

  1. Packages I will use to read in and plot the data.
  1. Read the data in from part 1.
number_of_deaths_by_risk_factor <- 
  read_csv(here::here("_posts/2022-05-09-project-part-2/number-of-deaths-by-risk-factor copy.csv"))

Interactive Graph

number_of_deaths_by_risk_factor %>%
  group_by(Entity) %>%
  e_charts(x = `Deaths - Cause: All causes - Risk: Air pollution - Sex: Both - Age: All Ages (Number)`, timeline = TRUE) %>%
  e_timeline_opts(autoplay = TRUE) %>%
  e_bar(serie = Year) %>%
  e_title(text = 'Deaths by Air Pollution in Afghanistan') %>%
  e_legend(show = FALSE)

Static Graph

number_of_deaths_by_risk_factor %>%
  ggplot(aes(x = Year, y = `Deaths - Cause: All causes - Risk: Air pollution - Sex: Both - Age: All Ages (Number)`,
             fill = Entity)) +
  geom_line() +
  colorspace::scale_fill_discrete_divergingx(palette = "roma", nmax =228) +
  theme_classic() +
  theme(legend.position = "bottom") +
  labs(y = "deaths in billions", 
       fill = NULL)

This shows how many deaths there were from 1990 to 2019.

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