View source: R/body_add_flextable.R
body_add_flextable | R Documentation |
add a flextable into a Word document.
body_add_flextable(
x,
value,
align = NULL,
pos = "after",
split = NULL,
topcaption = TRUE,
keepnext = NULL
)
x |
an rdocx object |
value |
|
align |
left, center (default) or right. |
pos |
where to add the flextable relative to the cursor, one of "after", "before", "on" (end of line). |
split |
set to TRUE if you want to activate Word option 'Allow row to break across pages'. |
topcaption |
if TRUE caption is added before the table, if FALSE, caption is added after the table. |
keepnext |
Defunct in favor of |
library(officer)
# autonum for caption
autonum <- run_autonum(seq_id = "tab", bkm = "mtcars")
ftab <- flextable(head(mtcars))
ftab <- set_caption(ftab, caption = "mtcars data", autonum = autonum)
ftab <- autofit(ftab)
doc <- read_docx()
doc <- body_add_flextable(doc, value = ftab)
fileout <- tempfile(fileext = ".docx")
# fileout <- "test.docx" # uncomment to write in your working directory
print(doc, target = fileout)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.