davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
245 stars 44 forks source link

barplot won't print unless executed in place #213

Closed sbellan61 closed 7 years ago

sbellan61 commented 7 years ago
mydoc <- pptx()# title = "title" )
mydoc <- addSlide( mydoc, slide.layout = "Title and Content" )
## myPlot = qplot(Sepal.Length, Petal.Length, data = iris,  ## **works**
##   color = Species, size = Petal.Width, alpha = I(0.7) )
## mydoc = addPlot(mydoc, fun = function()  barplot(1:8, col = 1:8, fg='white', col.axis='white')) ## **works**
 myPlot = barplot(1:8) ## **doesn't work**
mydoc <- addPlot( doc = mydoc, fun = print, x = myPlot, 
  offx = 1, offy = 1, width = 6, height = 5 )
mydoc <- addFlexTable( doc = mydoc, FlexTable( head( iris ) ),
  offx = 8, offy = 2, width = 4.5, height = 3 )
filename <- "force_pos_size.pptx" # the document to produce
writeDoc( mydoc, file = filename )

Error in .jcall(slide, "I", "add", dml.object, width, height, offx, offy) : javax.xml.bind.UnmarshalException

davidgohel commented 7 years ago

You have this error because myPlot contains a vector not a ggplot object, print(myPlot) is not producing any plot.