plot_pyramid

0th

Percentile

Plot an age pyramid from age pyramid data frame.

Plot an age pyramid from age pyramid data frame with possibly several characteristics. See also plot_population.

Usage
plot_pyramid(
  pyramid,
  group_colors,
  group_legend = "Group",
  age_breaks,
  value_breaks
)
Arguments
pyramid

Age pyramid of a population. Dataframe containing at least age and value columns.

(Optional) For plotting an age pyramid composed of several subgroups, the population data frame must contain a column named group_name.

group_colors

(Optional) Named character vector.

group_legend

(Optional) Legend title name. By default set to "Group".

age_breaks

(Optional) An ordered vector of indexes of vector unique(pyr$age) used for breaks for the axis of ages.

value_breaks

(Optional) Breaks for the axis of values.

Value

Plot of the age pyramid.

Aliases
  • plot_pyramid
Examples
# NOT RUN {
plot_pyramid(subset(EW_pop_14$age_pyramid, as.numeric(age) <= 110))

# }
# NOT RUN {
library(colorspace)
pyr_IMD <- subset(EW_popIMD_14$age_pyramid, as.numeric(age) <= 110)
pyr_IMD$group <- with(pyr_IMD, ifelse(male, paste('Males - IMD', IMD), paste('Females - IMD', IMD)))
colors <- c(sequential_hcl(n=5, palette = "Magenta"),
            sequential_hcl(n=5, palette = "Teal"))
names(colors) <- c(paste('Females - IMD', 1:5),
                   paste('Males - IMD', 1:5))
# note that you must have setequal(names(colors), pyr_IMD$group) is TRUE
plot_pyramid(pyr_IMD, colors)
# }
Documentation reproduced from package IBMPopSim, version 0.3.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.