Re: [R] Transfer Crosstable to Word-Document

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Tue, 19 Feb 2008 10:14:15 -0700

There are several options available to you depending on your knowledge and workflow.

Others have mentioned using Excel to format the table and to copy that into word, one thing along those lines that has not been mentioned yet is that if you have your data in a matrix or data frame then (on windows at least, I have not tried on other platforms) you can type:

> write.table(my.data, 'clipboard', sep="\t")

Then in Excel just do a paste and the data is there, this saves a couple of steps from saving as a .csv file and importing that into excel. This would probably be fine for a few tables.

With a little effort on your part, odfWeave may still be an option. I have a project based on a survey with quite a few questions, but the output wanted was basically one of 3 tables and graphs based on a question or set of questions. I wrote a set of functions that found the correct columns in the data and created a matrix with the appropriate table values and used the odfTable function to do the formating (and a set of functions to do the graphs). Then I created an odf template file in OpenOffice that called the appropriate functions for each question, ran that through odfWeave, opened the result in OpenOffice and saved it as a word file to send to the clients. Another nice thing about this approach is that occasionally I get requests for the same output on a subset of the data, I just create the subset, rerun odfWeave, convert to word and I'm done (I don't let the client know that it was that easy though). I think there is something in the works to allow conversion of odf files to ms word files from a command line.

You can also use the existing LaTeX tools that others have suggested, then convert from latex to HTML or RTF or another format that can be read into word. If you take this approach wich will require a few intermediate steps between R and word, then you may want to learn the make utility (there are versions of make available on windows, otherwise I don't know how I would survive trapped in an MS workplace). Make helps with automating several step processes and updating only those parts that need to be updated.

If you can give some more detail on what you want to do and how you want the output to look, then we can give more specific ideas on how to get there.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow_at_imail.org
(801) 408-8111
 
 


> -----Original Message-----
> From: Udo König [mailto:ukoenig_at_med.uni-marburg.de]
> Sent: Sunday, February 17, 2008 11:08 AM
> To: r-help_at_r-project.org
> Cc: Greg Snow
> Subject: RE: [R] Transfer Crosstable to Word-Document
>
> Zitat von Greg Snow <Greg.Snow@imail.org>:
>
> > If your final goal is a word document, then you should look at the
> > odfWeave package.
>
> Greg,
> I had a look at the odfWeave package, but it seems that
> complex tables, for instance produced with latex(....) can´t
> be produced/included, as can be done with sweave.
>
>
> --------------------------------------------
> Udo König
> Clinic for Child an Adolescent Psychiatry Philipps University
> of Marburg / Germany
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
______________________________________________ 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.
Received on Tue 19 Feb 2008 - 17:24:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Feb 2008 - 12:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive