Skip to contents

Renderers call as_tlf_table() on their input, so anything with a method can be rendered under tlfstack conventions:

Usage

as_tlf_table(x, ...)

Arguments

x

Object to convert.

...

Passed to methods. For card objects: by, the name of the grouping variable for gtsummary::tbl_ard_summary(). It is inferred when the ARD has a single grouping variable.

Value

A tlf_table (see tlf_table_result()).

Details

  • tlf_table: returned unchanged.

  • data.frame: cells printed as-is.

  • gtsummary objects (for example from tbl_summary() or tbl_hierarchical()): the visible columns with their header labels and row indentation. gtsummary footnotes, abbreviations and source notes become builder footnotes, placed after the title-block footnotes. The Analysis Results Data behind the table is kept in meta$ard for QC.

  • card objects (Analysis Results Data from cards/cardx): formatted through gtsummary::tbl_ard_summary().

Markdown emphasis in gtsummary labels (**bold**, _italic_) is removed, because the RTF text layer uses one font convention. A header line break before N = xx becomes (N = xx).

Examples

as_tlf_table(data.frame(Parameter = "Age", Value = "42"))
#> <tlf_table> 1 row(s) x 2 column(s)
#>  Parameter Value
#>  Age       42   
if (requireNamespace("gtsummary", quietly = TRUE)) {
  gt <- gtsummary::tbl_summary(ex_adsl, by = TRT01A, include = c(AGE, SEX))
  tb <- as_tlf_table(gt)
  tb$footnotes
}
#> [1] "Median (Q1, Q3); n (%)"