plot_growth: Utility functions for adding growth standard bands to...

panel.whoR Documentation

Utility functions for adding growth standard bands to ggplot2/lattice plots

Description

Utility functions for adding growth standard bands to ggplot2/lattice plots

Usage

panel.who(
  x,
  x_var = "agedays",
  y_var = "htcm",
  sex = "Female",
  p = c(1, 5, 25, 50),
  color = NULL,
  alpha = 0.15,
  center = FALSE,
  labels = TRUE,
  x_trans = identity,
  y_trans = identity
)

panel.igb(
  gagebrth,
  var = "lencm",
  sex = "Female",
  p = c(1, 5, 25, 50),
  color = NULL,
  alpha = 0.15,
  center = FALSE,
  labels = TRUE,
  x_trans = identity,
  y_trans = identity
)

panel.igfet(
  gagedays,
  var = "hccm",
  p = c(1, 5, 25, 50),
  color = "green",
  alpha = 0.15,
  center = FALSE,
  labels = TRUE,
  x_trans = identity,
  y_trans = identity
)

geom_growthstandard(
  mapping = NULL,
  data = NULL,
  x_seq,
  x_var = "agedays",
  y_var,
  sex = "Female",
  p = c(1, 5, 25, 50),
  shade = NULL,
  alpha = 0.15,
  center = FALSE,
  x_trans = identity,
  y_trans = identity,
  standard = "who",
  inherit.aes = TRUE
)

geom_who(...)

geom_igb(..., var = "lencm")

geom_igfet(..., var = "hccm", color = "green")

Arguments

x, x_seq

value or vector of values that correspond to a measure defined by x_var. x_seq is used with geom_*

x_var

x variable name (typically "agedays")

y_var

y variable name (typically "htcm" or "wtkg")

sex

"Male" or "Female"

p

centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)

color, shade

optional color to use for bands (will use sex to determine if not specified). shade is used with geom_*

alpha

transparency of the bands

center

should the bands be centered around the median?

labels

should the centiles be labeled? (not implemented)

x_trans

transformation function to be applied to x-axis

y_trans

transformation function to be applied to y-axis

gagebrth

gestational age at birth in days (for igb plots)

var

variable name for y axis for igb or igfet plots ("lencm", "wtkg", or "hcircm" for igb; "accm", "bpdcm", "flcm", "hccm", or "ofdcm" for igfet)

gagedays

gestational age in days (for igfet plots)

data, mapping, inherit.aes

supplied direclty to ggplot2::layer

standard

standard name to use. Either "who", "igb", or "igfet"

...

items supplied direclty to geom_growthstandard

Examples

## Not run: 
#### ggplot2

library(ggplot2)
p <- ggplot(data = subset(cpp, subjid == 8), aes(x = agedays, y = htcm)) +
  geom_who(x_seq = seq(0, 2600, by = 10), y_var = "htcm") +
  geom_point()

#### lattice

library(lattice)
xyplot(wtkg ~ agedays, data = subset(cpp, subjid == 8),
  panel = function(x, y, ...) {
    panel.who(x = seq(0, 2558, by = 30),
      sex = "Male", y_var = "wtkg", p = 100 * pnorm(-3:0))
    panel.xyplot(x, y, ...)
  },
  col = "black"
)

# look at Male birth lengths superposed on INTERGROWTH birth standard
# first we need just 1 record per subject with subject-level data
cppsubj <- subset(cpp, !duplicated(cpp$subjid))
xyplot(birthlen ~ jitter(gagebrth), data = subset(cppsubj, sex == "Male"),
  panel = function(x, y, ...) {
    panel.igb(gagebrth = 250:310, var = "lencm", sex = "Male")
    panel.points(x, y, ...)
  },
  col = "black", alpha = 0.75,
  xlab = "Gestational Age at Birth (days)", ylab = "Birth Length (cm)"
)

## End(Not run)

HBGDki/growthstandards documentation built on Jan. 14, 2024, 4:03 a.m.