age_sex_pyramid: Create age-sex pyramid

Description Usage Arguments Value Author(s) Examples

View source: R/age_sex_pyramid.R

Description

Create age-sex pyramid

Usage

1
2
3
age_sex_pyramid(data, age.grp.col, sex.col, lower.limit = NULL,
  upper.limit = NULL, split.by = NULL, col.pal = 1,
  blank.background = FALSE)

Arguments

data

a data.frame

age.grp.col

a character defining the age-group column within the data.frame

sex.col

a character defining the sex column within the data.frame

lower.limit

a numeric defining the lower limit for the x-axis

upper.limit

a numeric defining the upper limit for the x-axis

split.by

a character defining a column to facet by within the data.frame

col.pal

a numeric defining the colour palette to use

blank.background

a logical specifying if the figure background should be blank

Value

an age-sex pyramid

Author(s)

Daniel Gardiner (daniel.gardiner@phe.gov.uk)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# set dummy data

set.seed(5)

data = data.frame(sex = sample(c("Male", "Female", "Unknown"), 200, replace = TRUE),
                  age = sample(c(NA, 1:100), 200, replace = TRUE),
                  status = sample(c("Confirmed", "Probable"), 200, replace = TRUE))

data$age.grp = cut(as.numeric(data$age), breaks = c(0, 5, 15, 25, 45, 65, Inf),
                   include.lowest = TRUE)

# age sex pyramid

age_sex_pyramid(data, age.grp.col = "age.grp", sex.col = "sex", split.by = NULL)

# age sex pyramid with lower/upper limit and colour palette

age_sex_pyramid(data, age.grp.col = "age.grp", sex.col = "sex", split.by = NULL,
                lower.limit = -50, upper.limit = 40, col.pal = 4)

# age sex pyramid with facet

age_sex_pyramid(data, age.grp.col = "age.grp", sex.col = "sex", split.by = "status")

DanielGardiner/EpiFunc documentation built on July 25, 2019, 10:53 p.m.