I do not know if this belongs here. However, I hope that the question fits in here and that someone can give a hint as to its solution.
I like R graphics. When preparing a presentation or thelike, I love the option to just create some "fancy" graphs and import these as "Metafile" into Powerpoint. However, there is one major draback with this method: Boxplots created with R and saved as "Metafile" are corrupted whenever I try to store any Microsoft Office Document as PDF. I had this issue on several Computers and couldn't find no solution but to use other formats like .bmp. However, I'd really appreciate to use the Metafile option.
I create a Boxplot in RStudio:
boxplot(mtcars$disp)
then I use the export
function --> copy to clipboard
. Here, I can choose between "bitmap" and "metafile". I'd prefer to use "metafile" here.
Then I paste the image in Powerpoint. The last step is to save the pp-presentation as a PDF.
The following images are copied with the snipping tool from the final pdf:
this is the boxplot copied to clipboard
in RStudio as bitmap.
This is the Boxplot copied to clipboard
in RStudio as metafile.
Is there any suggestion of how to avoid the nasty lines?
There's a new package export
that just came out on CRAN that allows you to export graphs to Powerpoint or Word in native Office format. From there you can then save as PDF in Office without problems, without any weird lines appearing, see
https://cran.r-project.org/web/packages/export/index.html and
https://github.com/tomwenseleers/export
E.g.
install.packages("export")
library(export)
boxplot(count ~ spray, data = InsectSprays, las = 2)
graph2doc(file="plot.docx", width=7, height=5)
graph2ppt(file="plot.pptx", width=7, height=5)
Even after saving to PDF within Powerpoint this will give you a perfect quality vector format PDF without any weird lines :
Other advantage is that the Powerpoint version you get is fully editable vector format, enabling you to make any small required changes in the layout (it also fully supports transparency / alpha channels).