# 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)
# }
Run the code above in your browser using DataLab