rofficerflextablemodelsummary

Saving modelsummary resulting flextable as .docx lose horizontal line that separates estimates from goodness of fit measure


Consider the following example:

library(modelsummary)
library(flextable)
library(officer)

modlm <- lm(gear ~ mpg + wt, data = mtcars)
res <- modelsummary(
  modlm,
  stars = TRUE,
  out = "flextable"
)

If I save the resulting flextable as HTML, I get an horizontal line that separates estimates from goodness of fit measures:

res |> flextable::save_as_html(path="test.html")

enter image description here

However, if I save the flextable as docx, I lose such line:

section_prop <- officer::prop_section(
 page_size = officer::page_size(
 orient = "landscape"
 )
)
res |> flextable::save_as_docx(path="test.docx", pr_section=section_prop)

enter image description here

How can I have the horizontal line back?


Solution

  • This appears to be a bug. Could you report the issue here?

    In the meantime, you may fix it manually like so (works on MacOS):

    res <- res |> hline(i = 6, border = fp_border(color = "black"), part = "body")
    

    Word Screenshot:

    enter image description here