Add a section with a table and its legend
Arguments
- doc
a
rdocxobject- x
a table:
crosstable,flextable, or plain olddataframe- legend
the legend to use
- ...
passed on to
flextable::body_add_flextable()orbody_add_crosstable()- bookmark
the bookmark to use. Defaults to the cleaned variable name of
x- title
the title to add for the section. Can also be
FALSE(no title) orTRUE(the title defaults tolegend)- title_lvl
the title level if applicable
- sentence
a sentence to add between the title (if applicable) and the table. If
TRUE, defaults to"Information about {tolower(title)} is described in Table @ref({bookmark})".
Examples
library(officer)
read_docx() %>%
body_add_title("Description", 1) %>%
body_add_title("Population A", 2) %>%
body_add_table_section(head(iris), "The iris dataset", sentence=TRUE) %>%
body_add_table_section(crosstable(iris), "A crosstable of the iris dataset",
title=FALSE, sentence=TRUE, body_fontsize=8) %>%
write_and_open()
