Plots the growth chart, optionally including matches

process_chart(
  target,
  chartcode,
  curve_interpolation = TRUE,
  quiet = TRUE,
  con = NULL,
  dnr = NULL,
  period = numeric(0),
  nmatch = 0L,
  user_model = 2L,
  exact_sex = TRUE,
  exact_ga = FALSE,
  break_ties = TRUE,
  show_realized = FALSE,
  show_future = FALSE,
  clip = TRUE,
  target_height = list(show = TRUE, alpha = 0.95)
)

Arguments

target

A list with elements "psn" and "xyz", e.g. as produced by bdsreader::read_bds()

chartcode

A string with chart code

curve_interpolation

A logical indicating whether curve interpolation shoud be applied.

quiet

Logical indicating whether chart code should be written to standard output. Default is quiet = TRUE.

con

A connection on which the donor data reside. The default (NULL) reads from donorloader package.

dnr

A string with the name of the donor data (currently available are smocc, terneuzen, lollypop, pops, 0-2, 2-4 and 4-18). The default (NULL) sets the donor data according to period[2].

period

A vector of length 2 with left and right ages (decimal age). If length(period) == 0L, then no curve matching is done

nmatch

Integer. Number of matches needed. When nmatch == 0L no matches are sought.

user_model

Model number (1-4), indicating type of model the user wants. See details.

exact_sex

A logical indicating whether sex should be matched exactly

exact_ga

A logical indicating whether gestational age should be matched exactly

break_ties

A logical indicating whether ties should broken randomly. The default (TRUE) breaks ties randomly.

show_realized

A logical indicating whether the realized growth of the target child should be drawn

show_future

A logical indicating whether the predicted growth of the target child should be drawn

clip

A logical indicating whether clipping is needed

target_height

A list with two elements: show (logical) and alpha (numeric, e.g. 0.50 or 0.95).

Value

A gTree that can be rendered by grid::grid.draw().

The meaning of the user_model parameter is as follows:

1

most recent measurement only

2

sex + growth curve up to current

3

2 + all complete covariates

4

3 + growth curves up to current, other measures

Examples

if (FALSE) { # \dontrun{
library(grid)
fn <- system.file("extdata", "bds_v2.0", "smocc", "Laura_S.json", package = "jamesdemodata")
target <- bdsreader::read_bds(fn)
g <- process_chart(target,
  chartcode = "NJAA", show_realized = TRUE, show_future = TRUE,
  dnr = "0-2", period = c(0.5, 1.1667), nmatch = 10)
grid.draw(g)

# using lollypop for matching
g <- process_chart(target,
  chartcode = "NJAA", show_realized = TRUE, show_future = TRUE,
  dnr = "2-4", period = c(0.5, 1.1667), nmatch = 10
)
grid.draw(g)
} # }