Learn R Programming

flextable (version 0.10.0)

as_flextable.TableTree: Transform an rtables object into a flextable

Description

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().

Usage

# S3 method for TableTree
as_flextable(x, indent_padding = 4, ...)

# S3 method for ElementaryTable as_flextable(x, indent_padding = 4, ...)

Value

a flextable object.

Arguments

x

a TableTree or ElementaryTable object produced by the 'rtables' package.

indent_padding

base left padding in points per indentation level. Default is 4.

...

unused arguments

See Also

split_to_pages(), split_rows(), split_columns()

Examples

Run this code
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)
}

Run the code above in your browser using DataLab