Rmarkdown文件的yaml块中的内联R代码

时间:2017-06-09 18:42:10

标签: r markdown r-markdown pandoc

内联R代码似乎在yaml块的某些字段中运行良好,但在其他领域则不然。例如,这可以按预期工作,并在日期字段中插入R生成日期:

---
title: "docx template"
author: "Dave Braze"
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
  word_document:
    toc: true
    toc_depth: 2
    highlight: "tango"
    pandoc_args:
    - --reference-docx
    - resources/FDB-styles.docx
    - --output
    - docx-template-20170609.docx
---

但是这不会,在pandoc_args部分阻塞内联R。

---
title: "docx template"
author: "Dave Braze"
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
  word_document:
    toc: true
    toc_depth: 2
    highlight: "tango"
    pandoc_args:
    - --reference-docx
    - resources/FDB-styles.docx
    - --output
    - '`r paste0("docx-template-", format(Sys.time(), "%Y%m%d"), ".docx")`'
---

这是我得到的错误:

" C:/ PROGRA〜2 / Pandoc / pandoc" + RTS -K512m -RTS docx-template.utf8.md - to docx - from markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash --output docx-template.docx --table-of-contents --toc-depth 2 - highlight-style tango --reference-docx resources / FDB-styles.docx --output" r paste0(\"docx-template-\", format(Sys.time(), \"%Y%m%d\"), \".docx\")" pandoc.exe:r paste0("docx-template-", format(Sys.time(), "%Y%m%d"), ".docx"):openBinaryFile:无效参数(无效参数) 警告:运行命令"" C:/ PROGRA~2 / Pandoc / pandoc" + RTS -K512m -RTS docx-template.utf8.md - to docx - from markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash --output docx-template.docx --table-of-contents --toc-depth 2 - highlight-style tango --reference-docx resources / FDB-styles.docx --output" r paste0(\"docx-template-\", format(Sys.time(), \"%Y%m%d\"), \".docx\")"'有状态1 错误:pandoc文档转换失败,错误1

似乎很清楚内联R的第二位没有被解释,但我不知道从哪里开始。有什么想法吗?

0 个答案:

没有答案