【问题标题】:Got this error when knitting word doc using R mark down使用 R markdown 编织 word doc 时出现此错误
【发布时间】:2018-03-20 05:29:45
【问题描述】:

使用 r markdown 编织 word doc 时出现此错误。检查了我的代码几次,但找不到任何东西。请帮忙。谢谢 输出文件:Midterm.knit.md

Error: Functions that produce HTML output found in document targeting docx output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: yes

Note however that the HTML output will not be visible in non-HTML formats.

Execution halted

【问题讨论】:

  • 您必须在重现此错误的问题中包含一个最小示例代码。

标签: r r-markdown


【解决方案1】:

您的一个代码块将生成 HTML 输出。由于您没有提供可生产的示例,因此很难确切知道是哪一个,但它很可能是交互式图表或地图。

停止编译的原因是无法在 Word 文档中包含 HTML。 Word 文档需要静态图像。以下代码将产生您的错误:

---
title: "Untitled"
output: word_document
---

```{r}
library(DT)
datatable(iris, options = list(pageLength = 5))
```

要完成这项工作,最简单的方法是只输出到 HTML 文档:

---
title: "Untitled"
output: html_document
---

```{r}
library(DT)
datatable(iris, options = list(pageLength = 5))
```

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-22
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    • 2021-12-18
    相关资源
    最近更新 更多