在R中将多个回归表输出到Word文档的多页中 [英] Output several regression tables into multiple pages of a Word document in R

查看:32
本文介绍了在R中将多个回归表输出到Word文档的多页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是创建一个多页 Microsoft Word 文档,在连续页上有许多格式化的回归表输出.理想情况下,这将使用 R Markdown 来完成.

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.

我有幸使用 sjPlot::tab_model

例如,我可以做

mod2 <- lm(Petal.Length ~ Species + Petal.Width, data=iris) 
sjPlot::tab_model(mod2, file = "~/Desktop/model2.doc")

在新的 Word 文档中创建一个漂亮的回归表.

to create a nice-looking regression table in a new Word document.

如果我这样做

mod3 <- lm(Petal.Length ~ Species + Petal.Width, data=iris) 
sjPlot::tab_model(mod2, file = "~/Desktop/model3.doc")

我可以用另一个格式良好的回归表制作第二个 Word 文档.

I can make a second Word document with another nicely formatted regression table.

此处的目标是创建一个 Word 文档,其中包含连续页面上的两个模型输出.

The goal here is to create a single Word document containing both model outputs on consecutive pages.

我知道在 R Markdown 中,我可以使用 Stargazer 和 Knit 制作多页回归表,例如,

I know that in R Markdown, I can make multi-page regression tables using Stargazer and Knit, e.g.,

观星者(mod2)

但这些仅以 PDF 或 HTML 格式呈现.

But these only render in PDF or HTML.

我知道 sjPlot 不直接编织到 Word,所以这不是一个选项.

I know that sjPlot doesn't directly knit to Word, so that's not an option.

可能的解决方案包括:

  1. 使用不同的包在 Markdown 中呈现与 Word 兼容的回归输出表
  2. 找到一种巧妙的方法将 tab_model 输出合并到一个 Word 文档中.
  3. 我没有想到的其他方式.
  1. Using a different package to render Word-compatible regression output tables in Markdown
  2. Finding a clever way to combine the tab_model outputs into a single Word document.
  3. Some other way I'm not thinking of.

推荐答案

我想通了.最好的方法是坚持使用 sjPlot,编织到 HTML,然后从 HTML 复制并粘贴到 Word.表格以这种方式呈现得很好.

I figured it out. The best way is to stick with sjPlot, knit to HTML, then copy and paste from HTML to Word. The table renders nicely that way.

感谢 Andrew Reece (andrew_reece) 提供的这一服务.

Thanks to Andrew Reece (andrew_reece) for this one.

这篇关于在R中将多个回归表输出到Word文档的多页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆