Hi Folks,
later today, I plan on posting a web page of the following (with  
formatting to make it legible). I thought you might be interested in  
this, and may have specific comments for improvement.

How To Get Graphics Out of R and Into Microsoft Word and PowerPoint

This document describes a little of the how's and why's of getting  
graphics out of R and into MS Word and PowerPoint. It is also how to  
get graphics into the Open Office Suite and NeoOffice on a Mac.  
Please consider suggestions for improvements to this document.

Mac OSX uses PDF format for vector-graphics format, and R can make  
PDFs beautifully -- try opening them in Preview or Acrobat Reader.   
Microsoft Word, however, cannot handle PDF graphics, and uses EMF/WMF  
format for vector graphics. On PC's, R can create EMF/WMF format, but  
it does not do so on Macs.

Note that if you make a Word document (like a manuscript) that  
contains EMF/WMF graphics, Word on the Mac cannot read graphics in the
Word file made on the PC.

My Motivation
While I do not use Microsoft Word for my own work, I
(i) I teach R to people who use Word and PowerPoint, and
(ii) many people who use Word around here would also like to use R,  
but are frustrated about getting graphics into Word.

How to do it
Step 1.
Learn about how to save graphics in R. Graphics are "graphics  
devices" that can be saved as files in a variety of formats,  
including PDF, PNG, PS, BMP, JPEG. Read the Mac R FAQ on quartz. Read  
up on ?quartz, ?bitmap, ?pdf. You might also be interested to see  
also ?postscript, ?jpeg.

Step 2.
Try following these instructions.

Use bitmap()
(I am not sure if this will work on computers without ghostscript - I  
would be interested to find out!)

    1. Save R graphic with bitmap, using a high resolution. I prefer  
400 dpi, but others suggest 300 dpi suffices.

       plot(1:8)
       dev.print(bitmap, "Myplot.png", res=400)

    2. Within MS Word, use the Insert:Picture:From File to add it  
into a Word document.  That will look very good.


Use an intermediate program.

    1. Save R images as PDFs
       plot(1:8)
       dev.print(pdf, "MyPlot.pdf")

    2. Open the file in GraphicConverter (a utility that comes with a  
Mac), or Preview (Apple's PDF viewer), and then save as JPEG format  
(with 100% resolution).

    3. Within MS Word, use the Insert:Picture:From File to add it  
into a Word document.  That will look very good.

Cut and Paste

     * You can always cut and paste a quartz() window into Word, but  
the image will be a little blurry. Other methods, including saving  
using jpeg() and png(), also give less than ideal results.



I found a couple relevant threads including http:// 
finzi.psych.upenn.edu/R/Rhelp02a/archive/34950.html

Acknolwedgements
Thanks to all those who make R possible and who make R available on  
the Mac. Thanks also to those who contributed to the above  
information through the R-help listserv, including Stefan Iacus,  
Simon Urbanek, Phillip Price, Ben Bolker, Byron Ellis, Federico  
Calboli, Richard De Veaux, Don McQueen, Mick McQuaid, Rob Knell,  
Brian Ripley, Duncan Murdoch, George Gilcrist. Thanks also to the  
folks at Mozilla for providing the HTML composer on which this was  
written. Please consider suggestions for improvements to the above  
document.

On Jan 29, 2007, at 7:35 PM, Phillip Price wrote:

>
> On Jan 29, 2007, at 4:20 PM, MHH Stevens wrote:
>
>> Hi Phil,
>> I found res=400 was clean enough for me. The documentation says  
>> something about needing ghostscript -- I have ghostscript, so I  
>> don't know if it would work without it. Do you know?
>> -Hank
>
> I don't know.  I, too, have ghostscript.  I've never tried removing  
> or hiding ghostscript and seeing if bitmap() still works.  I've  
> wondered about this, but I've always figured that if, someday, I  
> change my system and "break" bitmap(), I'll worry about it then.
>
> I'm glad it's working for you.
>
> --Phil
>

Dr. Hank Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/

"E Pluribus Unum"






        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to