简体   繁体   中英

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

I have developed a dashboard using R and the library shiny, where some different charts are displayed. These ones aren't static charts but they are generated dynamically according to some filters you can set through some bottons and so on.

The next step, what I am working on right now it would be to create a powerpoint report including those charts I have generated before. I got this piece of code so far:

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")

Being pa given chart created by plotly this way:

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))

There is no problem with this chart as it is correctly displayed on the shiny app (dashboard).

When executing the code above I am getting the next error on 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.]

I found something a similar post but it haven't been solved so far Add plots in PPTx without crashing R using addplot()

Does anyone know what is wrong? Thanks in advance!

ReporteRs does not support htmlwidgets. addPlot work with base plot commands, ggplot2, grid and lattice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM