RMarkdown:pandoc命令中的多个输入文件

RMarkdown:pandoc命令中的多个输入文件,r,knitr,r-markdown,pandoc,R,Knitr,R Markdown,Pandoc,Pandoc显然可以从多个文件中读取输入: pandoc[选项][输入文件]… 如果给定多个输入文件,pandoc将把它们全部连接起来 (它们之间有空行)在解析之前 我有: main.Rmd --- output: pdf_document --- After the above YAML front-matter, additional YAML input follows: --- myparams: blabla whatnot: testtest --- Now the mai

Pandoc
显然可以从多个文件中读取输入:

pandoc[选项][输入文件]…

如果给定多个输入文件,pandoc将把它们全部连接起来 (它们之间有空行)在解析之前

我有:

main.Rmd

---
output:
  pdf_document
---

After the above YAML front-matter, additional YAML input follows:

---
myparams: blabla
whatnot: testtest
---

Now the main body follows, using $myparams$ and $whatnot$ from the second YAML block...
---
myparams: blabla
whatnot: testtest
---
---
input-files: path-to/separate.yaml
output:
  pdf_document
---

Now the main body follows, having access to 
$myparams$ and $whatnot$ from the separate  YAML file...
问题:

如何将第二个YAML块分离到它自己的文件中,并将
rmarkdown
/
knitr
指向它,以便它们使用两个而不是一个输入文件发出pandoc命令?我是否可以在yaml前端指定\separate.yaml资产的
路径

$pandoc main.md separate.yaml --output main.pdf`
单独的.yaml

---
output:
  pdf_document
---

After the above YAML front-matter, additional YAML input follows:

---
myparams: blabla
whatnot: testtest
---

Now the main body follows, using $myparams$ and $whatnot$ from the second YAML block...
---
myparams: blabla
whatnot: testtest
---
---
input-files: path-to/separate.yaml
output:
  pdf_document
---

Now the main body follows, having access to 
$myparams$ and $whatnot$ from the separate  YAML file...
main.Rmd

---
output:
  pdf_document
---

After the above YAML front-matter, additional YAML input follows:

---
myparams: blabla
whatnot: testtest
---

Now the main body follows, using $myparams$ and $whatnot$ from the second YAML block...
---
myparams: blabla
whatnot: testtest
---
---
input-files: path-to/separate.yaml
output:
  pdf_document
---

Now the main body follows, having access to 
$myparams$ and $whatnot$ from the separate  YAML file...
如何将第二个YAML块分离到它自己的文件中,并将rmarkdown/knitr指向它,以便它们使用两个输入文件而不是一个输入文件发出pandoc命令

我过去也遇到过类似的问题,但我不需要YAML头,所以我对文件进行了预处理,删除了YAML头并合并了文件。我建议您做一些类似的事情,创建自己的脚本来预处理文件,然后再将其发送到rmarkdown/knitr

我可以在yaml前端指定\separate.yaml资产的路径吗

$pandoc main.md separate.yaml --output main.pdf`

不行。

谢谢。能否显示将
separate.yaml
文件附加到
main.Rmd
文件并使用knitr处理合并文件的最小工作代码?那会有帮助的,thanks@DanielKrizian您可以使用
head-n-1
获取
separate.yaml的“开始”,也可以使用
tail-n+2
获取
main.Rmd的“结束”。使用这两个命令,您可以轻松合并这两个文件。