My goal is to create a multi-page Microsoft Word document with many formatted regression table outputs on consecutive pages. Ideally this would be done using R Markdown.
I have had some luck making nicely formatted regression tables in word using sjPlot::tab_model
So for example, I can do
mod2 <- lm(Petal.Length ~ Species + Petal.Width, data=iris)
sjPlot::tab_model(mod2, file = "~/Desktop/model2.doc")
to create a nice-looking regression table in a new Word document.
If I do
mod3 <- lm(Petal.Length ~ Species + Petal.Width, data=iris)
sjPlot::tab_model(mod2, file = "~/Desktop/model3.doc")
I can make a second Word document with another nicely formatted regression table.
The goal here is to create a single Word document containing both model outputs on consecutive pages.
I know that in R Markdown, I can make multi-page regression tables using Stargazer and Knit, e.g.,
stargazer(mod2)
But these only render in PDF or HTML.
I know that sjPlot doesn't directly knit to Word, so that's not an option.
Possible solutions include:
- Using a different package to render Word-compatible regression output tables in Markdown
- Finding a clever way to combine the
tab_model
outputs into a single Word document. - Some other way I'm not thinking of.
huxreg
from thehuxtable
package and convert toflextable
withhuxtable::as_flextable()
. – Crossover