[R] Cannot generate a *.docx file

Yves S. Garret yoursurrogategod at gmail.com
Sun May 14 20:35:45 CEST 2017


Hello,

I have the following code example:

library(ReporteRs)

# Create a word document to contain R outputs
doc <- docx()

# Add a title to the document
doc <- addTitle(doc, "Simple Word document", level = 1)

# Add a paragraph of text into the Word document
cat("Output 1\n")
doc <- addParagraph(doc, "This.")
cat("Output 2\n")

# Write the Word document to a file
writeDoc(doc, file = "r-reporters-simple-word-document.docx")

When I run it, this is what I see:

source("writing_to_ms_word_new.R")
Output 1
Error in UseMethod("addParagraph") :
  no applicable method for 'addParagraph' applied to an object of class
"docx"

Why?  The library loads as it should.  So why am I getting the above error?

Thanks in advance.

	[[alternative HTML version deleted]]



More information about the R-help mailing list