knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(knitr)
knit_print.neverpaste <- function(x, ...) {
  knit_print(asis_output(paste("```{=openxml}",x,"```",sep="\n")))
}
knit_print.neverpaste_inline <- function(x, ...) {
  knit_print(asis_output(paste("`",x,"`{=openxml}",sep="")))
}

You can also use inline text: r "this is inline text" (<- like that).

createField <- function(file, bookmark) {

  instr <- paste("INCLUDETEXT", "  ", "\"", file, "\"", " ", bookmark, " ", "\\*", " ", "MERGEFORMAT", sep = "")

  full <- paste("
  <w:p>
   <w:pPr>
      <w:rPr>
         <w:b />
         <w:bCs />
      </w:rPr>
   </w:pPr>
   <w:r>
      <w:fldChar w:fldCharType=\"begin\" />
   </w:r>
   <w:r>
      <w:instrText xml:space=\"preserve\"> ", instr," </w:instrText>
   </w:r>
   <w:r>
      <w:fldChar w:fldCharType=\"separate\" />
   </w:r>
 </w:p>
 <w:p>
   <w:r>
      <w:fldChar w:fldCharType=\"end\" />
   </w:r>
 </w:p>", sep = "")

  structure(full, class = "neverpaste")
}

createField2 <- function(file, bookmark) {

  instr <- paste("INCLUDETEXT", "  ", "\"", file, "\"", " ", bookmark, " ", "\\*", " ", "MERGEFORMAT", sep = "")

  full <- paste("
   <w:pPr>
      <w:rPr>
         <w:b />
         <w:bCs />
      </w:rPr>
   </w:pPr>
   <w:r>
      <w:fldChar w:fldCharType=\"begin\" />
   </w:r>
   <w:r>
      <w:instrText xml:space=\"preserve\"> ", instr," </w:instrText>
   </w:r>
   <w:r>
      <w:fldChar w:fldCharType=\"separate\" />
   </w:r>
   <w:r>
      <w:fldChar w:fldCharType=\"end\" />
   </w:r>", sep = "")

  structure(full, class = "neverpaste")
}


createInline <- function(file, bookmark) {
  structure(createField2(file, bookmark), class = "neverpaste_inline")
}
createInline("stat.docx", "table1")


Gootjes/neverpaste documentation built on June 6, 2019, 8:44 a.m.