Skip to content

Tranferring R results to word prosessors

16 messages · Gabor Grothendieck, Romain Francois, Sébastien Bihorel +10 more

#
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

+----------------------------------------------------------------+
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185                        Fax : +47-5558-9879 |
| Email : backer at psych.uib.no    URL : http://www.galton.uib.no/ |
+----------------------------------------------------------------+
#
In Word use a fixed font such as Courier rather than a proportional
font and it will look ok.
On 2/9/06, Tom Backer Johnsen <backer at psych.uib.no> wrote:
#
Le 09.02.2006 15:41, Tom Backer Johnsen a ??crit :
Hi ,

One way could be to output in html format from R (with the R2HTML 
package) and then read back the html from your word processor

Romain
#
Tom Backer Johnsen <backer at psych.uib.no> wrote:
[...]
In case you're not talking about table-like output exclusively, reading
?Devices describes all the available kinds of graphical output.  Most of
these can then easily be included in MS Word.

Cheers,
#
I have added several convenient methods for sending data directly from R 
to Microsoft Word (report() function) in the svViews package (SciViews 
bundle). However, I still have to upload it to CRAN. I do it right now. 
It should be available in a couple of days.
Best,

Philippe Grosjean
Romain Francois wrote:
#
I agree that this is the best way. 

I often use Courier font with font size 10 that gives very good results.
On Thu, 2006-02-09 at 09:47 -0500, Gabor Grothendieck wrote:
#
Tom Backer Johnsen wrote:
Well whatever you do, don't start looking at LaTeX, because that will 
get you even more irritated at yourself for not having done it before.

  LaTeX is to Word as R is to what? SPSS?

  I've still not seen a pretty piece of mathematics - or even text - in 
Word.

Barry
#
Take a look at the facilities to write HTML output in library(R2HTML).  If 
you write an HTML file, you can then easily copy and paste it into your Word 
document, or from MS Word you can use the Insert menu. i.e.

library(R2HTML)
x=ftable(Titanic, row.vars = 1:3)
HTML(x,"Titanic.html")

Then from MS Word use Insert-> File and select Titanic.html and see the 
results.

I hope this helps

Francisco
#
There is some documentation online at:

http://www.latex-project.org/guides/

which would be a good starting place.

If you prefer a good book, The LaTeX Companion (aka TLC) is the place to
begin:

http://www.amazon.com/gp/product/0201362996


There is also a boxed set (expensive) of several books (including TLC)
available:

http://www.amazon.com/gp/product/0321269446


Finally, for dealing with EPS (or PDF) graphics (ie. R plots), the
online document "Using Imported Graphics in LaTeX and pdfLaTeX" is
excellent:

http://www.ctan.org/tex-archive/info/epslatex.pdf


HTH,

Marc Schwartz
On Thu, 2006-02-09 at 12:33 -0500, roger bos wrote:
#
One approach is to use LyX (http://www.lyx.org/).
This is a lot like using Word or other word processors
but it creates LaTeX.  You probably won't need to
know anything about TeX for a long time unless you
are doing really weird things.

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
roger bos wrote:

            
#
<<<
Yeah, but I don't understand LaTeX at all.  Can you point me to a good
beginners guide?
I like Math into LaTeX, by Gratzer.  
For a real beginners guide, there's one called first steps in LaTeX.
You might also want to look at issues of the PracTEX journal, many of which are for beginners (It's an online journal)

Peter

Peter L. Flom, PhD
Assistant Director, Statistics and Data Analysis Core
Center for Drug Use and HIV Research
National Development and Research Institutes
71 W. 23rd St
http://cduhr.ndri.org
www.peterflom.com
New York, NY 10010
(212) 845-4485 (voice)
(917) 438-0894 (fax)
#
<<<
If you prefer a good book, The LaTeX Companion (aka TLC) is the place
to begin:

http://www.amazon.com/gp/product/0201362996 

Peter L. Flom, PhD
Assistant Director, Statistics and Data Analysis Core
Center for Drug Use and HIV Research
National Development and Research Institutes
71 W. 23rd St
http://cduhr.ndri.org
www.peterflom.com
New York, NY 10010
(212) 845-4485 (voice)
(917) 438-0894 (fax)
I respectfully disagree.  TLC is a great book.  Absolutely.  But I
think it is overwhelming for a beginner.  

Peter
#
As much as I love LaTeX, I would be cautious on recommending it for
someone with a short term objective or does not really need to write
equations etc. 

Part of the reason is the initial step of getting the different
softwares required to make LaTeX work properly can be difficult.
However, I think this webpage does a good job of explaining it
http://www.math.aau.dk/~dethlef/Tips/introduction.html

WinEdt (http://www.winedt.com/) might also be worth checking out.

Regards, Adai
On Thu, 2006-02-09 at 14:11 -0500, Peter Flom wrote:
#
At 11:42 10.02.2006 -0300, CENDOYA, Maria Gabriela wrote:
That works -- to some extent.  But, that means that the formatting of the 
table is completely dependent on the number of spaces between the 
elements.  It is essentially the same kind of formatting of tables I did on 
my first typewriter about 40 years ago.  Any nontrivial change is 
troublesome, and you have to stick to fixed size fonts like 
Courier.  Modern editors have moved far beyond that point.

This is about generating a table in a text document from R type 
output.  This type of table increases flexibility in respect to formatting.
Yes.

Tom

+----------------------------------------------------------------+
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185                        Fax : +47-5558-9879 |
| Email : backer at psych.uib.no    URL : http://www.galton.uib.no/ |
+----------------------------------------------------------------+
4 days later
#
I started using LyX; it is very straightforward. Then, I started exporting to 
LaTeX and playing around with the LaTeX file (I found it faster than using 
LyX, and could take my file anywhere they had something that could manipulate 
text ---emacs, vim, nedit, whatever).

Googling you'll find _many_ LaTeX tutorials. Which one is best probably 
depends a lot on your preferences and learning style. 

As for books, I find "Guide to LaTeX" by Kopka & Daly (I think now in its 
fourth edition) far easier to use (to learn and for reference) than the 
series of LaTeX books by Goossens et al. and Lamport. (And I only need to 
haul around a single book, not 2 to 5). But then, again, this is surely a 
matter of personal taste.

HTH,

R.
On Thursday 09 February 2006 20:08, Patrick Burns wrote: