如何将缺少的YAML头信息添加到脚本中的.rmd R标记文件中?
我正在开发一个工作流,其中如何将缺少的YAML头信息添加到脚本中的.rmd R标记文件中?,r,r-markdown,pandoc,R,R Markdown,Pandoc,我正在开发一个工作流,其中 协作处理Google文档,然后 作为.docx与googledrive软件包一起下载 使用rmarkdown:pandoc_convert()转换为.rmd 应用的样式和徽标以及 呈现为.html和PDF以供分发 我目前在第3步挂断,.rmd文件没有头 pandoc_convert("example.docx", "markdown", output = "out.Rmd") 如何从工作流脚本中的另一个文件注入YAML? e、 g.本标题: --- title
pandoc_convert("example.docx", "markdown", output = "out.Rmd")
如何从工作流脚本中的另一个文件注入YAML?
e、 g.本标题:
---
title: "Title1"
html_document:
number_sections: yes
self_contained: yes
toc: yes
toc_depth: 3
toc_float: yes
---
假设您的标题位于
header.yaml
中。然后,只需读取两个文件并将其作为一个文件写入:
fulltext <- c(readLines("header.yaml"), readLines("out.Rmd"))
writeLines(fullText, "out2.Rmd")
全文是!谢谢,我知道这很简单,但以前从未使用读/写线。
header <- '---
title: "Title1"
html_document:
number_sections: yes
self_contained: yes
toc: yes
toc_depth: 3
toc_float: yes
---'
fulltext <- c(header, readLines("out.Rmd"))
writeLines(fullText, "out2.Rmd")