使用 R 和 Latex 自动化 Powerpoint 报告
我有一个经常使用的报告模板。分析是在 R 中完成的,但目前这是我的工作流程:
- 使用 R 运行分析并将结果导出到 csv 文件
- 使用 excel 宏读取数据,操作图表/创建表格
- 再次使用 excel,“自动化”将图表/表格发送到 Powerpoint
我接触 Latex、R 和可重复研究的次数越多,我觉得应该有一种方法可以留在 R 中并将我的结果发送到 Powerpoint。我知道有 R2PPT 包,但我正在尝试考虑所有选项。我不认为发送图表的图片会成为问题,更让我困惑的是表格的创建。
您能提供的任何帮助将不胜感激!不幸的是,是的,我需要继续使用PPT。
I have a report template that I use quite often. The analysis is completed in R, but at the moment here is my workflow:
- Use R to run the analysis and export the results to csv files
- Use excel macros to read in the data, manipulate chart/create tables
- Again using excel, "automate" the charts/tables to Powerpoint
The more I am exposed to Latex, R, and Reproducible Research, I feel like there should be a way to stay within R and send my results to Powerpoint. I know there is the R2PPT package, but I am trying to think of all options. I don't think sending pictures of my graphs will be an issue, it's more the table creation that has me stumped.
Any help you can provide will be greatly appreciated! Unforunately, yes, I need to continue to use PPT.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
可以从 R 自动化 PowerPoint 吗?即,启动它,访问对象模型等?
如果是这样,您应该能够直接在 PPT 中创建表格。
Can you automate PowerPoint from R? Ie, start it, get access to the object model, etc?
If so, you should be able to create the tables directly within PPT.
此解决方案的条件是您能够在通常使用 powerpoint 的位置显示 PDF。
你将需要:
1)乳胶
2)R
3)Beamer乳胶包。
其中,您可能需要搜索的唯一一个是 Beamer。然后,您可以打开一个新的 Latex 文档,为其指定文档类型 Beamer,然后像编写文章一样编写 Latex 和 R。将代码发送到 R,返回结果,排版结果就完成了。自从了解 Beamer 以来,我就没有再使用过 Powerpoint。
我发现您需要留在 Powerpoint 中,因此此建议可能没有用。话虽这么说,Beamer 输出为 PDF,我已经做过很多演示,其他人都使用 powerpoint 并且从未遇到过问题
This is a solution conditional on you being able to display PDF's where you would normally use powerpoint.
You will need:
1) LateX
2) R
3) Beamer latex package.
Of these the only one you may have to search for is Beamer. You can then open up a new latex document, give it document type beamer, and then write latex and R just like you would for an article. Send the code to R, get results back, typeset the results and you're done. I haven't been back to Powerpoint since I learned about Beamer.
I see that you need to remain within Powerpoint, so this advice is probably not useful. That being said, Beamer outputs to PDF, and I've given many presentations where everyone else used powerpoint and have never had a problem
看一下 sweave 和 odfSweave。您可以使用 sweave 将 R 报告生成为 pdf,然后复制/粘贴到 powerpoint 中,或者使用 odfweave 将报告生成为 LibreOffice odt 文件,然后打开该报告并从 LibreOffice 复制/粘贴到 powerpoint 中。
Take a look at sweave and odfSweave. You can produce R reports as pdfs using sweave and then copy/paste into powerpoint, or use odfweave to produce your report as an LibreOffice odt file, then open that and copy/paste into powerpoint from LibreOffice.
也许
R2PPT
是最好的解决方案。我开始探索的另一个选择是创建一个 Visual Basic 脚本 (.vbs),它打开 Powerpoint、插入幻灯片并插入由 R 生成的 EMF。Maybe
R2PPT
is the best solution. Another option I start exploring is creating a Visual Basic Script (.vbs) which opens Powerpoint, inserts slides and inserts EMFs generated by R.ReporteRs
包正是为了完成此工作流程而设计的。如果您的输出可能是 pdf 或 html,请务必考虑knitr
或slidify
,它们不支持.pptx
。但这里有一个使用ReporteRs
的示例:The
ReporteRs
package is designed to do exactly this workflow. If your output could be a pdf or html, definitely considerknitr
orslidify
, which do not support.pptx
. But here's an example usingReporteRs
:看一下我的新导出包,它刚刚从 CRAN 中出来,它允许将图形和统计表从 R 导出到 Powerpoint 和 Word。
请参阅 https://cran.r-project.org/web/packages /export/index.html 和
https://github.com/tomwenseleers/export。
例如:
Have a look at my new export package that just came out an CRAN and that allows one to both export graphs and statistical tables from R to Powerpoint and Word.
See https://cran.r-project.org/web/packages/export/index.html and
https://github.com/tomwenseleers/export.
For example: