View source: R/plot_age_distribution.R
plot_age_distribution | R Documentation |
Bar plot of the age distribution
plot_age_distribution(x)
x |
data.frame; the age distribution matrix. See age_distribution and aggregate_age_distribution. |
A ggplot object that can be further customized using the ggplot2 package.
United Nations, Department of Economic and Social Affairs, Population Division (2019). World Population Prospects 2019, Online Edition. Rev. 1.
# Import the age distribution for Greece in 2020:
age_distr <- age_distribution(country = "Greece", year = 2020)
plot_age_distribution(age_distr)
# Lookup table:
lookup_table <- data.frame(Initial = age_distr$AgeGrp,
Mapping = c(rep("0-39", 8),
rep("40-64", 5),
rep("65+" , 3)))
# Aggregate the age distribution table:
aggr_age <- aggregate_age_distribution(age_distr, lookup_table)
# Plot the aggregated age distribution matrix:
plot_age_distribution(aggr_age)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.