[R] What is the best way to have "R" output tables in an MS

Frank E Harrell Jr f.harrell at Vanderbilt.Edu
Fri May 7 15:09:05 CEST 2010

On 05/07/2010 07:45 AM, John Kane wrote:
> Let me see. I open a Word document and type,
> Dear Dr.Harrell,
> I open a new LaTeX document and type something like:
> \documentclass[10pt,a4paper]{letter}
> \usepackage[latin1]{inputenc}
> \usepackage{amsmath}
> \usepackage{amsfonts}
> \usepackage{amssymb}
> \address{your name and address}
> \signature{your signature}
> \begin{document}
> \begin{letter}{name and address of the recipient}
> \opening{saying hello}
> Dear Dr Harrell,
> For a manager or secretary who is panicky at the thought of using a computer and who thinks of it as a glorified typewriter, which one wins?
> I think it was the initial investment in learning how to use the software.  A simple WYSIWYG interface is learnable (is this a word?) in a few moments even if it may lead to some horrible results later.
> LaTex looks incredibly complicated to someone used to a fountain pen and an IBM Selectric typewriter (which was "the" high tec way of producing most documents in late 1960s and 1970s.
> Heck,when I learned to type we didn't even have electric typewriters!

Two comments.  First, having a library of LaTeX templates is a great 
starting point.  Second, Xerox did a head-to-head time-efficiency test 
many years ago of WYSIWYG word processing and markup languages by 
secretaries.  The markup language approach won easily.  This assumes 
that people don't mind learning things that take more than a day to learn.


> --- On Thu, 5/6/10, Frank E Harrell Jr<f.harrell at vanderbilt.edu>  wrote:
>> From: Frank E Harrell Jr<f.harrell at vanderbilt.edu>
>> Subject: Re: [R] What is the best way to have "R" output tables in an MS
>> To: r-help at r-project.org
>> Received: Thursday, May 6, 2010, 7:44 PM
>> Ted I can't resist offering my $.02,
>> which is that I'm puzzled why
>> LaTeX, being free, flexible, and powerful, is used only by
>> millions of
>> people and not tens of millions.
> du>
>> Frank
>> On 05/06/2010 03:07 PM, (Ted Harding) wrote:
>>> Replying to Chris's latest message for the sake of
>> preserving the
>>> thread, but deleting all of it to save space. Except:
>>> I had sympathy with Chris's original query, on the
>> grounds that
>>> it was a good enquiry in principle, essentially
>> pokinting towards
>>> the problem of incorporating R's formatted output (be
>> it tables,
>>> graphics, ... ) into document-preparation software,
>> whether it
>>> be noddy WYSIWYG like Word, or more sophisticated
>> "typesetting"
>>> software such as TeX, the Adobe stable and other DTP
>> software,
>>> or even the ancient UNIX troff dinosaur (re-evolved as
>> GNU groff,but
>>> stil roaming the plains and consuming tough
>> typesetting for breakfast
>>> just as its ancestor did).
>>> Given what he said in his latest message, I now have
>> even more
>>> sympathy. It's not about begging in the streets for
>> someone to
>>> charitably do the job for him! It's a job that could
>> be a service
>>> to many, and if it attracts enough enthusiasm from
>> enough of those
>>> who know how to do it then they will willingly plunge
>> in. That's
>>> how Free Software works.
>>> The issue is about the "enough enthusiasm" and the
>> "enough of
>>> those who know".
>>> Many (possibly almost all) of the people who have
>> developed R
>>> are mainly working with TeX/LaTex. R clearly has a
>> well-developed
>>> interface to that language. But there are many people
>> (of whom
>>> Chris has raised his head) who have needs or
>> preferences for other
>>> software of whom some (as Chris spelled out) may
>> totally lack
>>> support for R and LaTex, etc., from their
>> organisations.
>>> I've pondered such issues many times myself, being one
>> of the
>>> old nomadic troff-herders and still herding the
>> groffs.
>>> My routine approach is as Chris described: grab the
>> output from
>>> R (be it mouse-copied off-screen, from a saved file,
>> or for
>>> graphics from a file of the coordinates of the
>> graphical objects,
>>> or an EPS file), plant this into a groff document, and
>> wrap it
>>> in formatting tags so that it comes out nicely. A bit
>> time
>>> consuming, but since it's fairly straightforward in a
>> markup
>>> language like g/troff, not so very time-consuming; and
>> I dare
>>> say the same would be true for TeX/LaTex if
>> Sweave&   Co did
>>> not exist. However, I would hate to have to do it for
>> Word and
>>> the like! I bet that *is* time consuming.
>>> All of which is leading on to a suggestion that has
>> been lurking
>>> in my mind for a while.
>>> How about an R "device" called xml? This would
>> implement the XML
>>> "extensible markup language" which is basically
>> capable of
>>> encapsulating any formatted material.
>>> The existing R devices seem to be confined to
>> graphical output.
>>> XML can in principle cope with anything. Naturally,
>> its function
>>> would be to save to file, not display on screen.
>>> I believe that Word (and maybe other MS Office
>> software) can import
>>> XML. I know that XML can be converted to g/troff input
>> (I've done it).
>>> It can no doubt be converted to TeX/LateX input. I'm
>> not familiar
>>> enough with other document software to comment
>>> Then we would have a "universal" language for
>> formatted R output,
>>> suitable for importing formatted R output into
>> document preparation
>>> software. One would not need the full functionality of
>> XML.
>>> Up to a point (I'm far from being an XML guru) I'd be
>> prepared to
>>> assist with this, and in particular to test it out
>> with groff.
>>> Any comments? Might there be a better suggestion than
>> XML?
>>> Ted.
>> ______________________________________________
>> R-help at r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.

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

More information about the R-help mailing list