View source: R/as_flextable_rtables.R
| as_flextable.TableTree | R Documentation |
produce a flextable from a TableTree or
ElementaryTable object produced with the
'rtables' package.
The conversion uses formatters::matrix_form() to extract the
formatted content, column spans, alignments, indentation
and footnotes, then maps them to flextable features.
Indentation of row labels is rendered with left padding.
Label rows (LabelRow) are displayed in bold in the first column.
Content rows (ContentRow) are displayed entirely in bold.
When LabelRow groups exist, paginate() is applied so
that all rows belonging to the same group are kept together
on the same page in Word and RTF output.
To paginate the resulting flextable into multiple pages, use
split_to_pages(), split_rows(), or split_columns() after
calling as_flextable().
## S3 method for class 'TableTree'
as_flextable(x, indent_padding = 4, ...)
## S3 method for class 'ElementaryTable'
as_flextable(x, indent_padding = 4, ...)
x |
a |
indent_padding |
base left padding in points per indentation
level. Default is |
... |
unused arguments |
a flextable object.
split_to_pages(), split_rows(), split_columns()
if (require("rtables", character.only = TRUE, quietly = TRUE)) {
library(rtables)
lyt <- basic_table(title = "Demographic Summary") %>%
split_cols_by("ARM") %>%
split_rows_by("SEX") %>%
analyze("AGE", afun = mean, format = "xx.x")
tbl <- build_table(lyt, DM)
as_flextable(tbl)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.