I am trying to use ReporteRs to create a powerpoint by R. But when I use addplot
to insert plotly objects into pptx, it gives me an empty slide. I have done as the reference manual says for ggplot2 objects: fun = print
and an extra x
specifies a plot object, but it doesnt work. Perhaps a plotly object is not supported by the ReporteRs package ?
Here is my code:
library(webshot)
library(ReporteRs)
library(magrittr)
library(plotly)
library(MASS)
myplot=plot_ly(iris,x=~Species,y=~Sepal.Width,type='bar') %>%
layout(
title = "Sepal width of each type",
yaxis2 = list(
tickfont = list(color = "red"),
overlaying = "y",
side = "right",
title = ""),
xaxis = list(title=""))
myggplot<-ggplot(iris,aes(x=Species,y=Sepal.Width))+geom_bar(stat="identity")
pptx(title="title") %>%
addSlide(slide.layout = "Title and Content") %>%
addPlot(fun=print,x=myplot,vector.graphic=F) %>%
writeDoc(file = "SepalData.pptx" )
x=myplot
and x=myggplot
give different outcomes.
plotly objects are htmlwidgets, this format is not supported by ReporteRs.