- Packages I will use to read in tnd plot the data
- Read the data in from part 1
literate_and_illiterate <- read_csv(here::here("_posts","2022-04-27-project-part-1", "literate_and_illiterate.csv"))
Interactive Graph
- Start with the data
- Use e_charts to creat an e_chart with Year on the x axis
- Use e_river to build “rivers” that contain Literate and Illiterate populations. The depth of each river represents the percentage of illiterate and literate populations in the world
- Use e_tooltip to add a tooltip that will display based on the axis values
- Use e_title to add a title, subtitle and link to subtitle
- Use e_theme to change the theme to vintage
literate_and_illiterate %>%
e_charts(x=Year) %>%
e_river(Literate) %>%
e_river(Illiterate) %>%
e_tooltip(trigget="axis") %>%
e_title(text = "Literate and Illiterate World Population",
sublink = "https://ourworldindata.org/grapher/literate-and-illiterate-world-population",
left="center")
Static Graph
- Start with the data
- Use pivot_longer to put the literate and illiterate columns together
- Use ggplot to create a new ggplot object. Use aes to indicate that Year will be mapped the x axis; percent will be mapped to the y-axis; Status will be the fill variable
- geom_area will display Illiterate and Literate percentages
- theme_classic set the theme
- theme(legend.position = “bottom”) puts the legend at the bottom of the plot
- labs sets the y axis label to “percent”, NULL indicates that the fill variable will not have the labelled region
These plots show a steady increase in literacy in the world population from 1930-2016. Literacy has continued to increase.
ggsave(filename = here::here("_posts", "2022-05-12-project-part-2", "preview.png"))