This function customizes the column headers, optional spanning header, and table caption for a gtsummary table. It supports adding a feature name, total label, group title, and formats missing data presentation.

custom_headers(
  base_table_missing,
  var_characteristic = NULL,
  show_missing_data = TRUE,
  show_n_per_group = TRUE,
  var_tot = NULL,
  var_group = NULL,
  group_title = NULL,
  table_title
)

Arguments

base_table_missing

A gtsummary table object (typically output from previous steps).

var_characteristic

Optional. A string to label the features column.

show_missing_data

Logical. If TRUE, adds missing data info to column headers.

show_n_per_group

A boolean indicating whether to display group sizes (n) for each level of the grouping variable.

var_tot

Optional. A string to label the total column.

var_group

Optional. Name of a grouping variable for adding a spanning header.

group_title

Optional. Title for the spanning header. If NULL, uses the variable label or name.

table_title

Title for the entire table.

Value

A gtsummary table object with updated headers, spanning header, and caption.