Problems with R officedown when used in an automated task

178 Views Asked by At

I have a script that creates a .docx document with all the nice formatting I have configured using officedown ("xxx.Rmd"). It runs perfectly when I execute it and produces the expected result.

This is the script:

setwd("xxx")

rmarkdown::render(
  input = "xxx.Rmd",
  output_file = "xxx.docx",
  envir = parent.frame()
)

However when I automate its execution with taskscheduleR, the output is not nice. The Table of Contents, for instance, becomes this (see below), and I loose all figures and page breaks I configured.

<w:p><w:pPr/><w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"><w:rPr/><w:fldChar w:fldCharType="begin" w:dirty="true"/></w:r><w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"><w:rPr/><w:instrText xml:space="preserve" w:dirty="true">TOC \o "1-3" \h \z \u</w:instrText></w:r><w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"><w:rPr/><w:fldChar w:fldCharType="end" w:dirty="true"/></w:r></w:p>

Is there something I can do to use scheduleR and officedown and get nice outputs?

0

There are 0 best solutions below