Indentation

Testing Indentation output

The example table evaluates Indentation.

library(gtsummary)
tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall()

gt_table <- tbl$table_body |> 
  gt::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 = "") |> 
  # Indentation
  gt::text_transform(
    locations = gt::cells_body(columns = label, rows = !row_type %in% "label"),
    fn = function(x) paste0(strrep("\U00A0", times = 2), x)
  ) |> 
  gt::text_transform(
    locations = gt::cells_body(columns = label, rows = row_type %in% "missing"),
    fn = function(x) paste0(strrep("\U00A0", times = 4), x)
  ) 

gt_save PDF

gt::gtsave(gt_table, filename = "outputs/pdf/indentations_gt_pdf.pdf")

Preview the Output

rmarkdown rendered PDF

gt_table

Preview the Output

gt_save rendered word file

gt::gtsave(gt_table, filename = "outputs/docx/indentation_gt_word.docx")

Preview the Output

quarto rendered word file

gt_table

Preview the Output

rmarkdown rendered word file

gt_table

Preview the Output the Output](outputs/indentations_word.docx)