Descriptive Summary Table (no gtsummary) using gt/flextable
Source:R/descriptive_table.R
descriptive_table.RdPublication-ready summary of categorical and continuous variables (optionally stratified). Mimics the OG gtsummary style: * column headers include N, e.g. "Overall, N=200" * categorical rows shown as n (%) * continuous rows default to Median (IQR) (footnote reflects summary)
Arguments
- data
data.frame
- exposures
Character vector of variables to summarise. Quoted names are recommended in scripts, and bare names are also accepted.
- by
Optional single grouping variable. Quoted and bare names are accepted.
- percent
"column" (default) or "row"; aliases like "col"/"rows" accepted
- digits
integer; decimals for % and continuous stats (default 1)
- show_missing
"ifany" (default) or "no"
- show_dichotomous
"all_levels" (default) or "single_row"
- show_overall
"no" (default), "first", or "last"
- statistic
Optional summary type for numeric variables. Use a single value such as
"mean"ormeanfor all numeric variables, or a named vector such asc(age = mean, ftv = categorical). Supported values are"mean","median","mode","count", and"categorical". Use"categorical"for numeric ordinal variables that should be shown as n (%).- value
optional named list for single-row binaries (e.g., list(sex="Female")); formula entries like list(sex ~ "Female") are also accepted
- format
"flextable" (default) or "gt"
- theme
preset or primitives
Value
A list with class c("gtregression", "descriptive_table", ...)
containing:
tableA
gt_tblorflextable.table_displayDisplay-ready data.
table_bodyLong audit data with variable, level, and type.
variable_labelsNamed character vector of display labels used for variables.
- metadata
Additional metadata fields.
Details
If variables have a "label" attribute, for example from
labelled::var_label(), those labels are used automatically in the
displayed table. Internal matching still uses the original column names.