r - 在knitr中指定多种同时输出格式(新)

标签 r yaml knitr r-markdown

我可以编写一个YAML标头以使用knitr为R Markdown文件生成多种输出格式吗?我无法重现the original question with this title答案中描述的功能。

这个降价文件:

---
title: "Multiple output formats"
output: 
    pdf_document: default
    html_document:
      keep_md: yes
---

# This document should be rendered as an html file and as a pdf file


产生pdf档案,但没有HTML档案。

和这个文件:

---
title: "Multiple output formats"
output: 
  html_document:
    keep_md: yes
  pdf_document: default
---

# This document should be rendered as an html file and as a pdf file


生成HTML文件(和md文件),但不生成pdf文件。

后一个示例是对original question的解决方案。我尝试使用Shift-Ctrl-K和RStudio中的“编织”按钮进行编织,以及调用rmarkdown::render,但是无论使用哪种方法生成输出文件,都只会创建一种输出格式。

可能相关,但我无法确定解决方案:


How do I produce R package vignettes in multiple formats?
Render all vignette formats #1051
knitr::pandoc can't create pdf and tex files with a single config #769
Multiple formats for pandoc #547
three year old RStudio blog post中对多种输出格式支持的暗示


使用R版本3.3.1(2016-06-21),knitr 1.14,Rmarkdown 1.3

最佳答案

我实际上在Render all vignette formats #1051中简要提到过,而您却错过了它:

rmarkdown::render('your.Rmd', output_format = 'all')


它记录在帮助页面?rmarkdown::render上。

关于r - 在knitr中指定多种同时输出格式(新),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44685485/

相关文章:

R:你能指定 reshape /类型转换的可变列的顺序吗?

r - 具有 osrm walk 或 foot profile 的服务器可在 R 中使用吗?

r - 访问作为 apply 内参数传递的变量名称

r - rmarkdown 中的 YAML 当前日期

r - 如何在 R markdown 中创建小节

r - R中更改变量名称的函数

java - 获取 YAML 路径下的所有节点

python - 纺织品解析 YAML

r - knitr 和 UTF8 编码

r - Markdown 与knitr 在一次编译中运行两组代码