Re: [R] Output and Word

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 18 Jul 2006 - 22:18:36 EST

If its text that you want included in a larger Word document you can create a text or HTML file from R and then when inserting it into Word insert it as a link rather than copying it in.

output a file from R
In Word

   Insert | File
   browse to the file so its name appears in the File name box    click on the down arrow to the right of the Insert button      and choose Insert as Link

If you regenerate the file in the future your Word document gets automatically uipdated.

Another possibility is either the rcom and RDCOMClient packages which allow one to control Word from R by treating Word as a COM object. This allows detailed control of Word but is more work. e.g. Here we create a Word document from scratch. Note that you must be running Windows and have Word on the machine where you do this:

library(RDCOMClient)
ow <- COMCreate("Word.Application")
ow[["Visible"]] <- TRUE # optional
od <- ow[["Documents"]]$Add()

od[["PageSetup"]][[LeftMargin"]] <- 20
od[["PageSetup"]][["TopMargin"]] <- 20

od[["Content"]][["Font"]][["Size"]] <- 11 od[["Content"]][["Text"]] <- "Hello World"

od$SaveAs("\\mydoc.doc")
ow$Quit()

On 7/17/06, sharon snowdon <sharonsnowdon@fastmail.fm> wrote:
> Hi
>
> I have just started to have a look at R. I have used most stats software
> packages and can use perl, visual basic etc. I am interested in how well
> it handles lots of output e.g. tables or charts. How would you get lots
> of output most easily and quickly into a Word document?
>
> Sharon Snowdon
>
>
>
> ------------------------------------------------------------------------
> -
> FIGHT BACK AGAINST SPAM!
> Download Spam Inspector, the Award Winning Anti-Spam Filter
> http://mail.giantcompany.com
>
>
>
> --
>
>
>
> 7/14/2006
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch 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 Jul 18 22:24:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 19 Jul 2006 - 00:17:16 EST.

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