[R] Transferring R results to word prosessors

Frank E Harrell Jr f.harrell at vanderbilt.edu
Fri Feb 10 00:10:51 CET 2006


Tom Backer Johnsen wrote:
> There has been an incredible number of responses in a short time, with a 
> number of different suggestions.  With hindsight, I must admit I have not 
> been quite clear, so additional (somewhat lengthy) explanation is needed.
> 
> I want to use R in an introductory course on multiple regression (among 
> other things) starting in two weeks time for students of psychology at my 
> University.  These students are very much used to MS Word, it is in 
> principle possible to get them to adopt OpenOffice (which I would like to), 
> but I regard Latex to be out of the question.
> 
> One of the things they are drilled on is that they have to produce term 
> papers etc. based on a template in APA (American Psychological Association) 

There's nothing wrong with the APA template; it will work well with LaTeX.

> format.  Among other things, this means that the document must be all text 
> apart from the graphics.  Therefore any kind of solution involving pictures 
> of tables rather than the tables / results as text is out.  Same holds for 
> all kinds of "mixed" output, so combinations of text with PDF 
> elements.  Besides, the tables in R are not that nice in respect to the 
> formatting.  Since the content is the main thing anyhow, that does not 

You have not seen the various R/latex interfaces for tables then.

> matter.  In most cases, the tables have to be tweaked as least to some 
> extent.  Given my inexperience, it seems that the R2HTML path is so far the 
> most promising (but for me untried so far)
> 
> One of the nice things about SPSS and Statistica is that it is VERY easy to 
> copy and paste output from the program right into the paper / paper.  A 
> commmon trick when using SPSS is to first paste the output into a 
> spreadsheet (e.g. Excel), and from there into the document.  In any case, 
> the outcome is that the output is a table (not a table in the R sense) in 
> the document, which may be edited, tweaked, adding borders etc..  So, what 
> I am looking for is a process starting with output from R (like what is 
> obtained from the summary(lm (...)) command, the output of a correlation 
> matrix, or ...) that could end up as a table in MS Word (and probably in 
> OpenOffice as well) in the smallest number of steps.

It sounds as if you are not interested in teaching students the 
principles of reproducible research, which is too bad. [See references 
towards the bottom of http://biostat.mc.vanderbilt.edu/StatReport].

> 
> For instance, if there was an option in R which had the effect that the 
> spaces separating things (e.g. the columns in the output of a correlation 
> matrix or the elements in an ANOVA table) were replaced by tabs, everything 
> would be very simple.  Then, you could (a) paste the output into the 
> document, and (b) do a simple text-to-table conversion in Word after the 
> paste.  A simple affair with a few simple steps.  Ideally, what I want for 
> me and my students is this or a similar solution to this problem.  That 
> might be a good selling argument for R as well.
> 
> Tom

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




More information about the R-help mailing list