Generate a normative summary for a given subject, including descriptive statistics, z-scores, and reproducible histogram/bar plots.

normativeSummary(
  data,
  subjectRow,
  columns,
  zoom = NULL,
  idcolumn = "commonID",
  sexcol = "commonSex",
  agecol = "commonAge",
  return_plot = FALSE,
  verbose = TRUE
)

Arguments

data

A data.frame containing the dataset.

subjectRow

Integer row index of the subject of interest.

columns

Character vector of column names to summarize.

zoom

Integer (optional). If provided, restricts summary to nearest zoom neighbors.

idcolumn

Column name containing the unique subject ID (default: "commonID").

sexcol

Column name for sex (default: "commonSex").

agecol

Column name for age (default: "commonAge").

return_plot

Logical. If TRUE, return a combined plot object as combined_plot.

verbose

Logical. If TRUE, print per-variable diagnostics.

Value

A list with elements:

  • summary — list of per-variable summaries (means, SD, z, p-values or freq tables),

  • plots — named list of ggplot objects (one per variable, plus "Z-Scores" if numeric present),

  • zplot — the z-score ggplot (or NULL),

  • combined_plot — (only returned when return_plot = TRUE) arranged grob of all plots.

Details

Notes on reproducibility:

  • Histogram ranges, binning, and scaling are computed from the population only (all rows except subjectRow). This ensures plots remain stable even if the chosen subject changes.

  • For categorical variables, NA values are dropped before building frequency tables. The subject's category is explicitly highlighted without introducing spurious levels (e.g., sex will always be two bars if binary in the data).