Search code examples
rms-wordflextable

Flextable Word output - How to display each table on a different page?


I have several tables that I want to save in a Word document.

Specifically, I would like to display each table on a different page.

How can I do this?

library(flextable)
head(mtcars)
FT=flextable(head(mtcars))
save_as_docx(values=list(FT,FT),path="result.docx")  

Solution

  • officer is a possible solution:

    library(officer)
    library(flextable)
    head(mtcars)
    FT=flextable(head(mtcars))
    read_docx() |> 
      body_add_flextable(FT) |> 
      body_add_break() |> 
      body_add_flextable(FT) |> 
      body_add_break() |> 
      print(target="result.docx")