library(gtsummary)
<- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall()
tbl
<- tbl$table_body |>
gt_table ::gt(caption = gt::md("This is the caption")) |>
gt::fmt_markdown(columns = label) |>
gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |>
gt::sub_missing(missing_text = "") |>
gt# Indentation
::text_transform(
gtlocations = gt::cells_body(columns = label, rows = !row_type %in% "label"),
fn = function(x) paste0(strrep("\U00A0", times = 2), x)
|>
) ::text_transform(
gtlocations = gt::cells_body(columns = label, rows = row_type %in% "missing"),
fn = function(x) paste0(strrep("\U00A0", times = 4), x)
)
Indentation
Testing Indentation output
The example table evaluates Indentation.
gt_save PDF
::gtsave(gt_table, filename = "outputs/pdf/indentations_gt_pdf.pdf") gt
rmarkdown rendered PDF
gt_table
gt_save rendered word file
::gtsave(gt_table, filename = "outputs/docx/indentation_gt_word.docx") gt
quarto rendered word file
gt_table
rmarkdown rendered word file
gt_table
Preview the Output the Output](outputs/indentations_word.docx)