Created
February 24, 2016 02:58
-
-
Save dreidpath/558493249638bb231761 to your computer and use it in GitHub Desktop.
Plot of the percentage variation within age group between the 1993 and 2016 UK populations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data: Percentage variation within age group between the 1993 and 2016 UK populations | |
# The data original data from which the numbers were derived come from: | |
# https://www.census.gov/population/international/data/idb/region.php?N=%20Results%20&T=10&A=separate&RT=0&Y=1993,2016&R=-1&C=UK | |
variation <- c(-10.9589041096, -13.5802469136, -12.987012987, -8.8235294118, -4.5454545455, | |
5.7971014493, 35.1851851852, 25.4901960784, 10.2040816327, 17.0212765957, 0, | |
6.6666666667, 24.9855625305) | |
age_grp <- c("20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80+") | |
# Plot the data | |
plot(variation, | |
main = "Percentage variation within age group between the\n1993 and 2016 UK populations", | |
ylab = "Variation", | |
xlab = "Age Groups", | |
ylim = c(-40, 40), | |
xaxt = "n") # Don't use the default axis labels | |
# Add appropriate age group axis labels | |
axis(1, at=1:length(age_grp), labels=FALSE) | |
text(1:length(age_grp), par("usr")[3] - 2, labels = age_grp, srt = 45, pos = 1, xpd = TRUE) | |
# Place a horizontal line where variation == 0 | |
abline(h=0) | |
# Add drop down lines between the poit and the line. | |
for(i in 1:length(age_grp)){ | |
segments(x0 = i, y0 = variation[i], x1 = i, y1 = 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment