viz_htwt: Height and Weight graphing function.

Description Usage Arguments Details Value Examples

Description

Uses CDC height and weight expected values to add percentile lines to height/age or weight/age graphs.

Usage

1
2
viz_htwt(p, category, sex, inf_only = FALSE, percentiles = c("P3", "P50",
  "P97"))

Arguments

p

a ggplot object.

category

"WT" for a weight/age graph and "HT" for a height/age graph.

sex

0 for female, 1 for male

inf_only

TRUE if all ages are less than three years old. Default is FALSE.

percentiles

Which percentiles to include. Vector values containing any of "P3", "P5", "P10", "P25", "P50", "P75", "P90", "P95", or "P97". Default is c("P3", "P50", "P97") percentile, upper percentile will automatically be calculated.

Details

See https://www.cdc.gov/growthcharts/percentile_data_files.htm for information on the data used to make percentile lines.

Value

Returns the ggplot object with lines representing the cdc growth-chart percentiles chosen.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(tidyverse)
# p1 plots age and weight for females
p1 <- ggplot(data = filter(htwt_example, SEX == 0)) +
  aes(y = WT, x = AGE_Y) +
  geom_point(alpha = .7) +
  theme_minimal()
p1 <- viz_htwt(p = p1,
               category = "WT",
               sex = 0)
p1
# p2 plots age and weight for male infants
p2 <- ggplot(data = filter(htwt_example, SEX == 1 & AGE_Y < 3)) +
  aes(y = WT, x = AGE_Y) +
  geom_point(alpha = .7) +
  theme_minimal()
p2 <- viz_htwt(p = p2,
               category = "WT",
               sex = 1,
               inf_only = TRUE,
               percentiles = c("P10", "P90"))
p2

jadonwagstaff/pkpd documentation built on May 15, 2019, 1:40 p.m.