[R] Output and Word

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 18 14:18:36 CEST 2006

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

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"


On 7/17/06, sharon snowdon <sharonsnowdon at 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
> ------------------------------------------------------------------------
> -
> Download Spam Inspector, the Award Winning Anti-Spam Filter
> http://mail.giantcompany.com
> --
> 7/14/2006
> ______________________________________________
> R-help at 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

More information about the R-help mailing list