Closed DanChaltiel closed 7 years ago
Hi
The following is OK:
library(ggplot2)
library(ReporteRs)
library(gridExtra)
p1 <- ggplot(data=mtcars, aes(x=cyl)) + geom_bar()
p2 <- ggplot(data=mtcars, aes(x=gear)) + geom_bar()
mydoc <- docx(title = "Test Doc")
mydoc <- addTitle(mydoc, "plot1",1)
mydoc <- addPlot(mydoc, fun = print, x = p1, vector.graphic = TRUE)
mydoc <- addTitle(mydoc, "plot2",1)
mydoc <- addPlot(mydoc, fun = print, x = p2, vector.graphic = TRUE)
p = grid.arrange(p1, p2, ncol=2)
mydoc <- addTitle(mydoc, "plot1 + plot2",1)
mydoc <- addPlot(mydoc, fun = function() print(cowplot::plot_grid(p)), vector.graphic = TRUE)
writeDoc(mydoc, "TestDoc.docx")
Hi David,
When I use
addPlot
to add some ggplots gathered withgrid.arrange
, the resulting plot in the docx is either null or white.Here is some code with comments :
Is this a bug or I'm using it wrong ?