ReporteRs崩溃了Rstudio

时间:2016-01-19 02:14:37

标签: r ggplot2 rstudio reporters

我正在尝试使用ReporteRs在R中创建一个powerpoint。我使用ggplot2创建了我的图表。我安装了ReporteRs没有问题,我可以创建一个新的pptx,添加一个幻灯片和标题,但是当它到达addPlot Rstudio时会在崩溃之前对它进行一些处理,给我一个R Studio中止并遇到的消息致命错误。有谁之前经历过这个吗?这是我的ReporteRs代码:

install.packages("ReporteRs")
library(ReporteRs)
WinR = pptx()
slide.layouts(WinR)
WinR = addSlide(WinR,"Title and Content")
WinR = addTitle(WinR, "Effect of Time on Total Root Length")
WinR = addPlot(WinR, Lengthplotfinal)`

Lengthplotfinal是之前开发的条形图

谢谢!

1 个答案:

答案 0 :(得分:4)

我已经重现了您的错误,将您的addPlot行更改为下面的行似乎有效。

请参阅http://davidgohel.github.io/ReporteRs/addPlot.html

上的示例
library(ReporteRs)
library(ggplot2)

#example plot
c <- ggplot(mtcars, aes(factor(cyl))) + geom_bar()


WinR = pptx()
slide.layouts(WinR)
WinR = addSlide(WinR,"Title and Content")
WinR = addTitle(WinR, "Effect of Time on Total Root Length")
WinR = addPlot(doc = WinR, x = c, fun = print)
writeDoc( WinR, "example.pptx" )