Learn R Programming

RastaRocket (version 1.0.2)

custom_format: Custom formatting for gtsummary tables

Description

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.

Usage

custom_format(gt_table, align = "right", column_size = NULL)

Value

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.

Arguments

gt_table

A gt table object (also handles gtsummary tables by converting them).

align

A character string defining the alignment of specific columns. Passed to the gt::cols_align() function (e.g., "left", "right", "center"). Default is "right".

column_size

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.

Examples

Run this code
# Example usage
tbl <- RastaRocket::desc_var(iris,
  table_title = "test",
  group = TRUE,
  var_group = "Species")
formatted_tbl <- custom_format(tbl,
  align = "center",
  column_size = list(label ~ gt::pct(50)))
formatted_tbl

Run the code above in your browser using DataLab