尝试在 powerpoint 模板上添加绘图时 R 崩溃

R crashes when trying to add a plot on a powerpoint template

我使用 R 和 shiny 库开发了一个仪表板,其中显示了一些不同的图表。这些不是静态图表,而是根据您可以通过一些按钮等设置的一些过滤器动态生成的。

下一步,我现在正在做的是创建一个 powerpoint 报告,包括我之前生成的那些图表。到目前为止我得到了这段代码:

report <- pptx(template = 'report_template.pptx')
report <- addSlide(report,"report_layout") 
slide.layouts(report)
slide.layouts(report, "report_layout")
report <- addPlot(report, function() print(p))
writeDoc(report, "example_report.pptx")

作为 plotly 以这种方式创建的给定图表:

p <- plot_ly(agregado_cedex(), labels = ~Escalado, values = ~Total,type = "pie",
          text = ~Total, width = 500, height = 250, hoverinfo = "none") %>% config(displayModeBar = FALSE) %>%
layout(title = "Desglose incidencias", showlegend = TRUE,
       xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
       yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

此图表没有问题,因为它已正确显示在闪亮的应用程序(仪表板)上。

执行上面的代码时,我在 R Studio 上遇到下一个错误:

Warning: Error in .jcall: javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.]

我发现了类似的东西 post 但目前还没有解决 Add plots in PPTx without crashing R using addplot()

有谁知道哪里出了问题?提前致谢!

ReporteRs 不支持 htmlwidgets。 addPlot 使用基本绘图命令、ggplot2、网格和点阵。