[R] exporting tables to word

Alexander Shenkin ashenkin at ufl.edu
Tue Apr 2 19:50:46 CEST 2013


Thanks Carlos,

ftable has some internal routines, it seems, that allow it to print out
a flat contigency table in a nice format.  Converting to data.frame ends
up messing up the display format, unfortunately.

thanks,
allie

On 4/2/2013 12:41 PM, Carlos Valenzuela wrote:
> You  may also want to consider the "rtf" package. It works okay. You would
> have to save your results as a dataframe and you would be able to write
> that object out to an .rtf (or even use an .doc extension, as I have seen
> it done).
>
> For example,
>
> library(rtf)
>
> # Your regression formula
> lmobj<-lm(dv~iv1 + iv2 + iv3, data=dat)
>
> lmresults<-as.data.frame(summary(lmobj)$coefficients)
>
> # Output location for .rtf file
> output<-"filepath/nameoffile.rtf"
>
> # Specify the width, height, font size, etc and margins
> rtfdoc<-RTF(output,width=8.5,height=11,font.size=10,omi=c(1,1,1,1))
>
> addHeader(rtf,title="Title of Table, subtitle="Subtitle")
> addTable(rtfdoc, lmresults, font.size=10, row.names=T, NA.string="-")
> done(rtf)
>
> This is a very crude example so I would suggest looking at the help files
> associated with the "rtf" package to make any modifications, such as adding
> other regression results/tables.
>
> Thanks and hope this helps,
>
> Carlos
>
>
> On Tue, Apr 2, 2013 at 12:13 PM, Alexander Shenkin <ashenkin at ufl.edu> wrote:
>
>> Thanks Frans,
>>
>> odfTable seems not to like ftable objects.  any thoughts?
>>
>> Error:  chunk 1 (label = damageTable)
>> Error in UseMethod("odfTable") :
>>   no applicable method for 'odfTable' applied to an object of class
>> "ftable"
>>
>>
>> thanks,
>> allie
>>
>> On 4/2/2013 8:09 AM, Frans Marcelissen wrote:
>>> Hi Allie,
>>> My preferred method is by means of odfWeave. Odfweave generates a
>>> libreoffice file, which can directly be transferred to word.
>>> A second way is run R from within spss. Spss has a much better output
>> than
>>> R, but you can use the output system of spss (by means of
>>> spsspivottable.Display())
>>> Frans
>>>
>>>
>>> 2013/4/2 Alexander Shenkin <ashenkin at ufl.edu>
>>>
>>>> Hello all,
>>>>
>>>> What is your preferred method to export tables (from ftable()) to Word?
>>>> Do you just export to a text file and then copy/paste?  Or perhaps via
>>>> HTML output?
>>>>
>>>> Thanks,
>>>> Allie
>>>>
>>>> ______________________________________________
>>>> 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.
>>>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>



More information about the R-help mailing list