[R] Tranferring R results to word prosessors

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu Feb 9 18:56:52 CET 2006


Marc Schwartz (via MN) wrote:
> In follow up to Harold's thought of using LaTeX, I have an approach when
> the use of nicely formatted tables is required in a document where LaTeX
> is not being used for the entire document. In other words, where you
> need to use Word, OO.org's Writer or similar application for the
> majority of the document body.
> 
> This involves outputting R results to LaTeX table code in a text file,
> processing the file with 'latex' and 'dvips' and creating an EPS file.
> Of course, the LaTeX text file is fully complete with preamble, etc.
> 
> One can then import the EPS file to a page in the document processor
> file. The most recent versions of the aforementioned applications will
> generate a bitmapped preview of the table content to aid in placement
> and review.
> 
> You can then print the document to a PS printer or file for subsequent
> use. OO.org's Writer can also use Ghostscript to print to a PDF file
> using a "PDF Converter" in the printer selection dialog. This,
> importantly, is different than the "Export to PDF" function. The latter
> does not properly print embedded EPS images and prints the bitmapped
> preview instead.
> 
> The advantage of this approach is that you don't have to mess around in
> the word processing program doing a 'text to table' conversion and then
> go through the formatting of the resultant columns, borders, etc.
> 
> HTH,
> 
> Marc Schwartz

In addition to Marc's nice idea, I have had luck with Linux programs 
latex2rtf (.tex to .rtf) and hevea (.tex to .html).  Most often I use 
hevea and let Word users quickly convert from .html to .doc.  Of course 
doing everything in LaTeX is far better, using either Sweave or 
http://biostat.mc.vanderbilt.edu/StatReport .  Personal productivity 
with LaTeX is amazingly greater than with Word.

Frank

> 
> On Thu, 2006-02-09 at 09:47 -0500, Doran, Harold wrote:
> 
>>Well, I don't know if it can be used with Word or not, but you might
>>consider Sweave for use with LaTeX. Maybe if you use the sink() command
>>this might work, but I haven't tried it. 
>>
>>-----Original Message-----
>>From: r-help-bounces at stat.math.ethz.ch
>>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Tom Backer
>>Johnsen
>>Sent: Thursday, February 09, 2006 9:41 AM
>>To: r-help at stat.math.ethz.ch
>>Subject: [R] Tranferring R results to word prosessors
>>
>>I have just started looking at R, and are getting more and more
>>irritated at myself for not having done that before.
>>
>>However, one of the things I have not found in the documentation is some
>>way of preparing output from R for convenient formatting into something
>>like MS Word.  An example:  If you use summary(lm(....)) you get nice
>>output.  However, if you try to paste that output into the word
>>processor, all the text elements are separated by blanks, and that is
>>not optimal for the creation of a table (in the word processing sense).
>>
>>Is there an option to generate tab-separated output in R ? That would
>>solve the problem.
>>
>>Tom
> 
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list