Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

flextable_to_rmd

flextable raw code


Description

Print openxml, latex or html code of a flextable. The function is particularly useful when you want to generate flextable in a loop from a R Markdown document.

Inside R Markdown document, chunk option results must be set to 'asis'.

All arguments whose name starts with ft. can be set in the chunk options.

See knit_print.flextable for more details.

Usage

flextable_to_rmd(
  x,
  ft.align = opts_current$get("ft.align"),
  ft.split = opts_current$get("ft.split"),
  ft.tabcolsep = opts_current$get("ft.tabcolsep"),
  ft.arraystretch = opts_current$get("ft.arraystretch"),
  ft.left = opts_current$get("ft.left"),
  ft.top = opts_current$get("ft.top"),
  text_after = "",
  webshot = opts_current$get("webshot"),
  bookdown = FALSE,
  pandoc2 = TRUE,
  print = TRUE
)

Arguments

x

a flextable object

ft.align

flextable alignment, supported values are 'left', 'center' and 'right'.

ft.split

Word option 'Allow row to break across pages' can be activated when TRUE.

ft.tabcolsep

space between the text and the left/right border of its containing cell, the default value is 8 points.

ft.arraystretch

height of each row relative to its default height, the default value is 1.5.

ft.left, ft.top

Position should be defined with options ft.left and ft.top. Theses are the top left coordinates in inches of the placeholder that will contain the table. Their default values are 1 and 2 inches.

text_after

The string you put here will be added after printing the content of the flextable. For example, you can put "\\pagebreak" here to have tables produced with page breaks.

webshot

webshot package as a scalar character, one of "webshot" or "webshot2".

bookdown

TRUE or FALSE (default) to support cross referencing with bookdown.

pandoc2

TRUE (default) or FALSE to get the string in a pandoc raw HTML attribute (only valid when pandoc version is >= 2.

print

print output if TRUE

See Also

Examples

demo_loop <- system.file(package = "flextable", "examples/rmd", "loop_with_flextable.Rmd")
rmd_file <- tempfile(fileext = ".Rmd")
file.copy(demo_loop, to = rmd_file, overwrite = TRUE)
rmd_file # R Markdown document used for demo
if(require("rmarkdown", quietly = TRUE)){
#  render(input = rmd_file, output_format = "word_document",
#    output_file = "loop_with_flextable.docx")
#  render(input = rmd_file, output_format = "html_document",
#    output_file = "loop_with_flextable.html")
#  render(input = rmd_file,
#    output_format = rmarkdown::pdf_document(latex_engine = "xelatex"),
#    output_file = "loop_with_flextable.pdf")
}

flextable

Functions for Tabular Reporting

v0.6.10
GPL-3
Authors
David Gohel [aut, cre], Clementine Jager [ctb], Quentin Fazilleau [ctb], Maxim Nazarov [ctb] (rmarkdown for docx output), Titouan Robert [ctb], Michael Barrowman [ctb] (inline footnotes), Atsushi Yasumoto [ctb] (support for bookdown cross reference), Paul Julian [ctb] (support for gam objects)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.