Processing
 

Unable to use a modified word template in RStudio knitr

20/09/2016 15:39#1

Joined at: 4 months ago

Post: 3

Thank: 0

Thanked: 0

Unable to use a modified Word template from Rstudio using Knit Word from Rstudio. Rstudio and required packages were installed and updated this week. Running OS X 10.10.5 and using Word 2011. Simplified testing to Yihui Xie's 113-externalization.rmd and 113-foo.R and have followed his Vimeo video https://vimeo.com/110804387 on this subject. In all cases, knitting the RMD file uses the default formats and not the modified template stored as template.docx. I have tried putting copies in all locations in the project directory without success.

#113-externalization.Rmd --- title: "Untitled" output:      word_document:       reference_doc: "template.docx" ---  # Code Externalization  ```{r cache=FALSE} knitr::read_chunk('113-foo.R') ```  The following two chunks are from the external R script `113-foo.R`:  ```{r test-a} ``` ```{r test-b} ``` #code for 113-foo.R # ---- test-a ---- 1 + 1 x = rnorm(10)  # ---- test-b ---- mean(x) sd(x) 

Search found Changing word template for knitr in Rmarkdown, but that failed to locate the modified template at any location in the project directory.

20/09/2016 19:54Top#2

Joined at: 4 months ago

Post: 1

Thank: 0

Thanked: 0

Pretty sure the indentation of the YAML header is the problem. Change it to:

--- title: "Untitled" output:   word_document:      reference_docx: "template.docx" --- 

I also just found out for myself that it does not make a difference if you use reference_doc or reference_docx.

20/09/2016 19:59Top#3

Joined at: 4 months ago

Post: 3

Thank: 0

Thanked: 0

Tried changing the reference thanks to Martin Smelter's comment and accidentally hit upon the solution.
Working YAML HEADER --- title: "Untitled" output: word_document: reference_doc: "template.docx" --- FAILING YAML HEADERS.

--- title: "Untitled" output:      word_document:       reference_doc: "template.docx" --- 

Putting everything in a single line also fails. I haven't found the documentation yet but it appears that a CR and or an indent is needed between the various entries in the output line.

Similar articles

VBA regex matching over two lines

4 months ago - Reply: 1 - Views: 44

Table output to Word-2011 from Rstudio using knit

4 months ago - Reply: 0 - Views: 32

Write a Collection of paragraphs into a new document

4 months ago - Reply: 1 - Views: 70

how to write paragraphs without show to document

4 months ago - Reply: 1 - Views: 66

numericals in word macro

4 months ago - Reply: 1 - Views: 45

Can not find proofing tools

4 months ago - Reply: 0 - Views: 1

Possible values for <w:outlineLvl> in Word OOXML

4 months ago - Reply: 1 - Views: 7

C# restrict editing partial word paragraph

5 months ago - Reply: 2 - Views: 142

Macro translation Please (possible virus)

4 months ago - Reply: 1 - Views: 34

Doc/Docx Fastest Reading Method for Searching

4 months ago - Reply: 0 - Views: 1

Save embedded file / content from word

4 months ago - Reply: 0 - Views: 5

Counting words in Word document, including footnores

4 months ago - Reply: 1 - Views: 22

c# access extract word ole object

4 months ago - Reply: 1 - Views: 19

Using word wildcards to find unaccepted changes

4 months ago - Reply: 1 - Views: 45

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re