[R] Exporting R graphics into Word without losing graph quality
    Steve Taylor 
    steve.taylor at aut.ac.nz
       
    Tue Dec 17 03:02:36 CET 2013
    
    
  
Unfortunately the win.metafile() device does not support semi-transparent colours, which I like using.
In my experience, the best way to get R graphics into Word is to use compressed high-resolution tiff, like this:
word.tif = function(filename="Word_Figure_%03d.tif", zoom=4, width=17, height=10, pointsize=10, ...) {
  if (!grepl("[.]ti[f]+$", filename, ignore.case=TRUE))
      filename = paste0(filename,".tif")
  tiff(filename=filename, compression="lzw", res=96*zoom, 
       width=width, height=height, units='cm', pointsize=pointsize, ...)
}
word.tif('test')
plot(rnorm(100))
dev.off()
Now drag the file test.tif into your Word document.
Sure, it's a bitmap format rather than a vector format, but the quality is excellent and the file sizes are still quite small.  None of the vector formats works as well as this.
cheers,
    Steve
    
    
More information about the R-help
mailing list