[R] R: Including R plots in a Microsoft Word document

Don MacQueen macq at llnl.gov
Fri Feb 20 19:39:28 CET 2004


At 11:08 AM -0600 2/20/04, Marc Schwartz wrote:
>On Fri, 2004-02-20 at 09:54, Mahmoud K. Okasha wrote:
>>  Greetings List,
>>
>>  I am conducting some large simulations using R. As a result, I get
>>  many plots but I'm having some trouble with including some of them in
>>  a Microsoft Word document. Can any one tell me the easiest method of
>>  having copies of the R-graphs in the Word documents?
>>
>>  Best regards
>>  Mahmoud
>
>
>A couple of different ways:
>
>1. If you actually need to see the graphics within the document and/or
>send the .doc file to someone who needs to be able to see the plots as
>they appear, then you should use Windows Metafile format images. Since
>these are vector format files, you can resize them as required on your
>pages. Bitmapped images (ie .BMP/.PNG) will distort as you resize them.
>You can generate these by plotting directly into an R plot window and
>then copy (ie. right mouse click) and paste into the Word document using
>the Windows clipboard, or generate the plot files directly using the
>win.metafile() function.

If you open the EPS file created as in (2) below with Adobe 
Illustrator, then save it as "Illustrator EPS", then a preview image 
will be added, and displayed on-screen when the file is imported into 
Word. This would of course be prohibitively tedious if there are too 
many files. pdf is the format I would try next, depending on how good 
Word is at importing, displaying, and printing an inserted pdf.

>2. If you will be generating hard copies of the documents using a PS
>printer, you can generate the graphics as EPS files using the
>postscript() function. Word can import EPS files, but you will see them
>only as place holders in your document (ie. a frame box) since Word
>cannot actually interpret the images for display. Keep in mind that the
>function has very specific argument requirements to enable the
>generation of EPS files. These include:
>
>horizontal = FALSE, onefile = FALSE, paper = "special"
>
>With these in place, you can then generate your plots to the EPS files
>and import them into your Word documents.
>
>See ?postscript for more information.
>
>If this is something that you will be doing with a level of repetition,
>you might want to look into using Sweave, which combines LaTeX and R to
>automate formatted report generation. More information is here:
>
>http://www.ci.tuwien.ac.at/~leisch/Sweave/
>
>There were also a couple of articles in RNews:
>
>Friedrich Leisch. Sweave, part I: Mixing R and LaTeX. R News,
>2(3):28-31, December 2002.
>
>Friedrich Leisch. Sweave, part II: Package vignettes. R News,
>2(2):21-24, October 2003.
>
>
>Frank Harrell also has a document at:
>
>http://cran.r-project.org/doc/contrib/Harrell-statcomp-notes.pdf
>
>HTH,
>
>Marc Schwartz
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list