Easy to do, but quicker to have it wrapped up in a plot.

ggplot_census_by_year_age_sex(census)

Arguments

census

a tibble of census counts with columns year and age, and then the counts of the different sexes in columns named male, and female.

Value

ggplot_census_by_year_age_sex() returns a ggplot object which is a stacked barplot with year on the x-axis, counts on the y-axis with fill mapped to age. It is facet-gridded with sex in the columns and populations in the rows.

Examples

# A single population example
g <- ggplot_census_by_year_age_sex(species_1_slurped_results$census_postkill)

# a three-population example
g3 <- ggplot_census_by_year_age_sex(three_pops_with_mig_slurped_results$census_postkill)