Search code examples
rreporters

How to add date to docx document using reporteRs in R?


I can only find information about adding a date (ideally the current date based on when the report is run) to pptx document in reporteRs. Is there a way to add the current date to a docx document?

Thank you!


Solution

  • Try

    library( ReporteRs )
    mydoc = docx( )
    mydoc = addParagraph( mydoc, value = as.character(Sys.time()), stylename = "Normal" )
    mydoc = addParagraph( mydoc, value = as.character(Sys.Date()), stylename = "Normal" )
    writeDoc( mydoc, file = tf <- tempfile(fileext = ".docx"))
    shell.exec(tf)
    

    enter image description here

    pptx works just like that...