Re: [R] Transferring R results to word prosessors

From: Gregory Snow <>
Date: Sat 11 Feb 2006 - 03:25:51 EST

Just to add a couple of thoughts to the previous suggestions.

If you really want output from things like summary.lm to have tabs instead of spaces then you can type: getAnywhere(print.summary.lm)

at the R prompt and it will show you the (not quite) source of code that R uses to do the printing to the console. Copy this to your favorite text editor and use it to create a new function (tabbed.summary.lm?), go through and find the places where it prints output and change the spaces to tabs (in some cases the inserted space is a default and you will not see it directly). You could even have the cat functions send the output directly to the clipboard rather than the screen.

I had one thought about using capture.output and gsub to replace series of spaces with tabs, but I think that would insert way to many tabs (but I have seen tabify functions elsware (emacs), perhaps that code could be rewritten in R to do what you want).

Others have suggested R2HTML and sweave, but I have not seen anyone else mention that R2HTML has an HTML driver for sweave. This means that you can write a fairly minimal HTML file (you could even use MSword to set this up, but use a text editor for the later parts) and insert your R commands into the HTML file. Run this through sweave using the HTML driver and the result is an HTML file (plus extra files for the graphics if any). MSword can then read in the HTML file and either save it as a word doc or cut and paste from it into a word doc, or best of all, just put everything you need in the original template file and have this be your final product.

R2HTML can also capture an entire set of output into an HTML file (see HTMLStart and HTMLStop) that could then be read into MSword.

Hope this helps, mailing list PLEASE do read the posting guide!

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide! Received on Sat Feb 11 03:42:58 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:27 EST