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
)
A data.frame containing the dataset.
Integer row index of the subject of interest.
Character vector of column names to summarize.
Integer (optional). If provided, restricts summary to nearest zoom
neighbors.
Column name containing the unique subject ID (default: "commonID").
Column name for sex (default: "commonSex").
Column name for age (default: "commonAge").
Logical. If TRUE, return a combined plot object as combined_plot
.
Logical. If TRUE, print per-variable diagnostics.
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.
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).