This function takes a gt table and applies custom formatting. It allows you to align columns,
apply bold text to certain rows, and adjust column widths if specified.
custom_format(gt_table, align = "right", column_size = NULL)A gt table object (also handles gtsummary tables by converting them).
A character string defining the alignment of specific columns. Passed to the
gt::cols_align() function (e.g., "left", "right", "center"). Default is "right".
A named list or vector defining the width of columns (optional). The list should specify the width for one or more columns. If not provided, column widths will not be modified.
A gt table object with the specified formatting applied.
The table will have columns aligned according to the align parameter,
and cells in the "label" rows will have bold text. If column_size is provided,
the column widths will be adjusted accordingly.
# Example usage
tbl <- RastaRocket::desc_var(iris,
table_title = "test",
group = TRUE,
var_group = "Species")
#> Note: 'var_group' is provided but 'by_group = FALSE'. The grouping variable will be ignored.
formatted_tbl <- custom_format(tbl,
align = "center",
column_size = list(label ~ gt::pct(50)))
formatted_tbl
test
Characteristic
N
Overall