What does it do?

If you have a dataset with several (or all!) countries/ regions/ ages/ etc and you want a short call function to plot without having to modify the ggplot2 code every time (e.g. a certain country for a certain year), here’s a solution.

Just save the r script with the function for the plot and call it when you want to use it:

pyramid_plot.R

The next step will be to use facet_wrap to select sub-national administrative units at once to be compared against the national plots.

Data can be found for Iraq at national level on my github page.

Below is the population pyramid for Iraq in year 2000