Title: | Reporting Tables |
---|---|
Description: | Rtables to officer |
Authors: | Gabriel Becker [ctb], Davide Garolini [aut], Emily de la Rua [aut], Abinaya Yogasekaram [aut], Joe Zhu [aut, cre], F. Hoffmann-La Roche AG [cph, fnd] |
Maintainer: | Joe Zhu <[email protected]> |
License: | Apache License 2.0 | file LICENSE |
Version: | 0.0.1.9003 |
Built: | 2024-11-12 12:33:31 UTC |
Source: | https://github.com/insightsengineering/rtables.officer |
From a table, produce a self-contained word document or attach it to a template word
file (template_file
). This function is based on the tt_to_flextable()
transformer and
the officer
package.
export_as_docx( tt, file, doc_metadata = NULL, titles_as_header = FALSE, footers_as_text = TRUE, template_file = NULL, section_properties = section_properties_default(), ... ) section_properties_default( page_size = c("letter", "A4"), orientation = c("portrait", "landscape") ) margins_potrait() margins_landscape()
export_as_docx( tt, file, doc_metadata = NULL, titles_as_header = FALSE, footers_as_text = TRUE, template_file = NULL, section_properties = section_properties_default(), ... ) section_properties_default( page_size = c("letter", "A4"), orientation = c("portrait", "landscape") ) margins_potrait() margins_landscape()
file |
( |
doc_metadata |
( |
template_file |
( |
section_properties |
( |
... |
( |
page_size |
( |
orientation |
( |
section_properties_default()
: Helper function that defines standard portrait properties for tables.
margins_potrait()
: Helper function that defines standard portrait margins for tables.
margins_landscape()
: Helper function that defines standard landscape margins for tables.
export_as_docx()
has few customization options available. If you require specific formats and details,
we suggest that you use tt_to_flextable()
prior to export_as_docx
. Only the title_as_header
and
footer_as_text
parameters must be re-specified if the table is changed first using tt_to_flextable()
.
library(flextable) lyt <- basic_table() %>% split_cols_by("ARM") %>% analyze(c("AGE", "BMRKR2", "COUNTRY")) tbl <- build_table(lyt, ex_adsl) # See how section_properties_portrait function is built for custom tf <- tempfile(fileext = ".docx") export_as_docx(tbl, file = tf, section_properties = section_properties_default(orientation = "landscape") )
library(flextable) lyt <- basic_table() %>% split_cols_by("ARM") %>% analyze(c("AGE", "BMRKR2", "COUNTRY")) tbl <- build_table(lyt, ex_adsl) # See how section_properties_portrait function is built for custom tf <- tempfile(fileext = ".docx") export_as_docx(tbl, file = tf, section_properties = section_properties_default(orientation = "landscape") )
This function creates a flat tabular file of cell values and corresponding paths via path_enriched_df()
. It then
writes that data frame out as a tsv
file.
export_as_tsv( tt, file = NULL, path_fun = collapse_path, value_fun = collapse_values, sep = "\t", ... ) import_from_tsv(file)
export_as_tsv( tt, file = NULL, path_fun = collapse_path, value_fun = collapse_values, sep = "\t", ... ) import_from_tsv(file)
file |
( |
sep |
( |
... |
( |
By default (i.e. when value_func
is not specified, list columns where at least one value has length > 1 are
collapsed to character vectors by collapsing the list element with "|"
.
export_as_tsv
returns NULL
silently.
import_from_tsv
returns a data.frame
with re-constituted list values.
There is currently no round-trip capability for this type of export. You can read values exported this way back in
via import_from_tsv
but you will receive only the data.frame
version back, NOT a TableTree
.
path_enriched_df()
for the underlying function that does the work.