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

Paul Johnson pauljohn at ku.edu
Fri Feb 20 20:47:51 CET 2004

I have wrestled with this problem a lot. I use Linux, coauthors use 
Windows, and the eps files I make from R don't work with MS Word.  Well, 
the don't ever have "previews" and they sometimes won't print at all 
when I use CrossOver Office with MS Office 2000 in Linux.  My coauthor 
says he can often wrestle my eps files into word on his system with 
Office 2003.  People keep telling me to use gsview to insert the preview 
panes into eps files, and that does work, but more than one half of the 
time my system creates eps files that look significantly worse than the 
originals.  Sometimes it inserts a blank page at the top of the eps or 
it reshapes a figure.  I don't care enough about MS to try to track that 
down.  It just pisses me off.

As a result, I think the answer is more complicated than other people 
make it seem.

I don't think it does any good to output a pdf file because, as  I 
learned yesterday, MS Word users can't import a pdf file into a doc.

Clearly, if you are an MS windows user of R, you can save graphics in 
the windows meta format (wmf)  (or is it enhanced meta format, emf?). 
That will go more or less seamlessly into Word.  If you have a chance to 
boot into Windows, and you really must make an image that works well 
with Word, then you should boot into Windows, run your R in there and 
make the wmf file.

If you are a Linux/Unix user, and you are too proud to use Windows,  the 
problem is much more difficult to deal with.

If you are ABSOLUTELY SURE that your image does not need to be resized 
in any way, you could output from R into a picture type format, such as 
png.  As long as the image does not need to resized in any way, that 
will be fine.  If it is resized, then all bets are off.

I find that the R output to the xfig format is quite good and I can edit 
files in xfig.  You can edit those files, add text, so its very very 
handy.  So right now I'm looking for a good bridge from xfig format to 
Word.  But I just started investigating that.

uaca at alumni.uv.es wrote:

>On Fri, Feb 20, 2004 at 05:54:33PM +0200, 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?
>R can produce at least PostScript, PDF, png, jpeg/jpg
>	help(postscript)
>	help(pdf)
>	help(png)
>	help(jpeg)
>I don't use word, for me the PostScript format (more precisely Encapsulated
>PostScript/.eps) is the best/more easy/powerful format if you don't have thousands of
>points or lines :-)
>por instance, to print a simple plot:
>dev.off(); <<---- Important
>other formats are similar
>	Ulisses
>                Debian GNU/Linux: a dream come true
>"Computers are useless. They can only give answers."            Pablo Picasso
>Humans are slow, innaccurate, and brilliant.
>Computers are fast, acurrate, and dumb. 
>Together they are unbeatable
>--->	Visita http://www.valux.org/ para saber acerca de la	<---
>--->	Asociación Valenciana de Usuarios de Linux		<---
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Paul E. Johnson                       email: pauljohn at ku.edu
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504                              
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700

More information about the R-help mailing list