Learn R Programming

crosstable (version 0.3.2)

body_add_crosstable: Add a crosstable to an officer document

Description

body_add_crosstable() adds such a flextable an officer document.

Usage

body_add_crosstable(
  doc,
  x,
  body_fontsize = NULL,
  header_fontsize = ceiling(body_fontsize * 1.2),
  padding_v = NULL,
  ...
)

Arguments

doc

a rdocx object, created by officer::read_docx()

x

a crosstable object

body_fontsize

fontsize of the body

header_fontsize

fontsize of the header

padding_v

vertical padding of all table rows

...

further arguments passed to as_flextable.crosstable()

Value

The docx object doc

Examples

Run this code
# NOT RUN {
#Officer
library(officer)
mytable = crosstable(mtcars2)
doc = read_docx() %>% 
    body_add_crosstable(mytable) %>% 
    body_add_break %>% 
    body_add_crosstable(mytable, compact=TRUE)

dfile = tempfile(fileext=".docx")
print(doc, target = dfile)
if(interactive()) browseURL(dfile)
# }

Run the code above in your browser using DataLab