Project Part 2

Interactive and static plots for the age of students in school

  1. Packages I will use to read in and plot the data
  1. Read the data in from part 1
countries_age  <- read_csv(here::here("countries_age.csv"))

Interactive Graph

countries_age   %>%
  group_by(Country)  %>%
  mutate(Age = round(Age, 2),
         Year = paste(Year, "12", "31", sep="-"))  %>%
  e_charts(x = Year)   %>% 
  e_river(serie = Age, legend=FALSE)  %>% 
  e_tooltip(trigger = "axis")  %>% 
  e_title(text = "Years in school by countries",
          subtext = "(Age in Years). Source: Our World in Data",
          sublink = "https://ourworldindata.org/grapher/expected-years-of-schooling?tab=chart",
          left = "center")  %>% 
  e_theme("roma")

Static Graph

countries_age   %>% 
  ggplot(aes(x = Year, y = Age, 
             fill = Country)) +
  geom_bin2d ()+
  colorspace::scale_fill_discrete_divergingx(palette = "roma", nmax =11) +
  theme_classic() +
  theme(legend.position = "bottom") +
  labs( y = "Age in Years",
       fill = NULL)

This graph shows a small increase for the age of students in school since 2000.

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