Creates a line plot of the percentage of children passing a specific item as a function of age, D-score, or other continuous item, optionally including individual-level responses as rug plots.

plot_p_a_one_item(
  pass,
  data_rug = NULL,
  item_var = "item",
  response_var = "response",
  x_var = "agemos",
  by_var = "cohort",
  by_value,
  i = 0,
  min_n = 10,
  model_name = "",
  xlim = c(0, 60),
  xbreaks = seq(0, 60, 6),
  xlab = "Age (in months)",
  label.trunc = 60,
  col.manual = NULL,
  na.value = "grey"
)

Arguments

pass

A data frame containing summarized pass rate data, with variables including item, p (percent pass), a (mean age), n (sample size), and cohort.

data_rug

Optional data frame of individual responses to the item, used to add rug plots. Should include item, age/dscore, response and cohort.

item_var

Only relevant for long shape. Character string with the name of the column containing item names. The default is item_var = "item".

response_var

Only relevant for long shape. Character string with the name of the column containing responses. The default is response_var = "response".

x_var

Variable representing the continuous x-axis (e.g., age in months, or D-score).

by_var

Variable by which to group the data for plotting.

by_value

Value of the item to filter and plot.

i

Item index or number (used for annotation).

min_n

Minimum number of observations required to include a point. Defaults to 10.

model_name

Optional model name used as annotation in the plot.

xlim

Numeric vector of length 2 specifying x-axis limits (in months). Defaults to c(0, 60).

xbreaks

Sequence of breaks for the x-axis. Defaults to seq(0, 60, 6).

xlab

Label for the x-axis. Defaults to "Age (in months)".

label.trunc

Maximum length of the item label to display.

col.manual

Optional named vector of manual colors by cohort. If NULL, colors are obtained using get_palette().

na.value

Color to use for missing values. Default is "grey".

Value

A ggplot object.