Function converts a gtsummary object to a flextable object. A user can use this function if they wish to add customized formatting available via the flextable functions. The flextable output is particularly useful when combined with R markdown with Word output, since the gt package does not support Word.
1 2 3 4 5 6
Object created by a function from the gtsummary package (e.g. tbl_summary or tbl_regression)
Commands to include in output. Input may be a vector of
quoted or unquoted names. tidyselect and gtsummary select helper
functions are also accepted.
Logical. Default is
When TRUE, all double asterisk (markdown language for bold weight) in column labels and spanning headers are removed. Default is TRUE
A flextable object
as_flex_table() functions converts the gtsummary object to a flextable,
and prints it with the following styling functions.
flextable::set_header_labels() to set column labels
flextable::add_header_row(), if applicable, to set spanning column header
flextable::align() to set column alignment
flextable::padding() to indent variable levels
flextable::fontsize() to set font size
flextable::autofit() to estimate the column widths
flextable::footnote() to add table footnotes and source notes
flextable::bold() to bold cells in data frame
flextable::italic() to italicize cells in data frame
flextable::border() to set all border widths to 1
flextable::padding() to set consistent header padding
flextable::valign() to ensure label column is top-left justified
Any one of these commands may be omitted using the
Pro tip: Use the
flextable::width() function for exacting control over
column width after calling
Daniel D. Sjoberg
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.