title: Producing a vector graphics image (i.e. metafile) in R suitable for printing in Word 2007
body: <p>First a caveat:  I posted this question <a href="https://superuser.com/questions/396582/incorporating-vector-graphics-metafile-figures-from-r-into-microsoft-word-2007">here</a> on SuperUser, but it is clearly the wrong place to ask R questions.  I recognize that it is not directly a programming question, but I believe it can be solved by changing how plots are produced (i.e. by coding appropriately).  So I hope readers find this appropriate for the forum.</p>
  
  <p>R plots usually consist entirely of vector graphics elements (i.e. points, lines, polygons, text).  R permits you to save your figure (or copy-paste) in various formats including various raster formats, as a PDF, or as a Windows meta-file.</p>
  
  <p>I usually save my images as PDFs and print them. This renders the images exactly as I intended them on paper, in the highest quality. I avoid raster formats (e.g. JPG, TIFF) for printing as inevitably the quality is poorer and publishers prefer vector formats.</p>
  
  <p>However, I need to make a large multi-page desktop published document using Microsoft Word 2007, and therefore using PDFs is not an option. When I import my figures from meta-files, or copy and paste directly from R into Word both the screen and print rendering of the image changes slightly (e.g. polygons and their fills become slightly misaligned).</p>
  
  <p>Given that I want to retain high vector quality (and not use raster formats), what can I do to make R vector graphics work with Word?  (Of course Sweave and LaTeX would be nice, but again, not a realistic option).</p>
  
  <p>Consider this example:</p>
  
  <pre><code>plot(c(1:100), c(1:100), pch=20)
  ## Copy and paste to Word 2007 as Windows metafile
  ## Print
  ## Quality is poorer (e.g. dot fills misaligned with borders)
  
  pdf("printsPerfectly.pdf")
  plot(c(1:100), c(1:100), pch=20)
  dev.off()
  ## Now print PDF
  ## Quality is as expected
  </code></pre>
  
  <p>EDIT:  Further to suggestions by @John I produced it as an EPS postscript file (see below), inserted it as a picture into Word.  Because ultimately it will be printed from a PDF created from Word, I converted it to a PDF using default Word 2007 settings, printed it on my HP Laserjet P1606dn laser printer, and then took aphotograph to illustrate the issue of polygons borders and fills misaligning (image on left, below).  I also produced it directly as PDF from R using <code>pdf()</code> and printed the PDF and took a photograph (image on right, below).</p>
  
  <p><img src="https://i.stack.imgur.com/53elG.jpg" alt="Illustration of misalignment (left) and perfection (right)"></p>
  
  <p>It may seem like small potatoes!  But when you have gone to a lot of trouble to achieve high quality, it is disappointing to be thwarted at the end.  In addition, it is not really obvious here, but the numerals are not as high-quality (left) as in the PDF (right), disregarding differences in focus on the photograph.</p>