R markdown compile error:

R markdown compile error:

当我尝试将 Rmarkdown 文档编译为 pdf 时,出现此错误:

    Error: Functions that produce HTML output found in document targeting latex 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.

有人知道这是什么意思吗?

你需要选择你想要编织成什么格式,试着看看我的。

---
title: "<img src='www/binary-logo.jpg' width='240'>"
subtitle: "[<span style='color:blue'>binary.com</span>](https://github.com/englianhu/binary.com-interview-question) Interview Question I"
author: "[<span style='color:blue'>®γσ, Lian Hu</span>](https://englianhu.github.io/) <img src='www/ENG.jpg' width='24'> <img src='www/RYO.jpg' width='24'>白戸則道®"
date: "`r Sys.Date()`"
output:
  tufte::tufte_html:
    toc: yes
  tufte::tufte_handout:
    citation_package: natbib
    latex_engine: xelatex
  tufte::tufte_book:
    citation_package: natbib
    latex_engine: xelatex
link-citations: yes
---

您尝试过以下方法吗? (来自:https://bookdown.org/yihui/bookdown/html-widgets.html

install.packages("webshot")
webshot::install_phantomjs()

它对我有用。另见:https://github.com/rstudio/bookdown/issues/440

我 运行 在使用 Bookdown 时遇到了这个问题,并且公认的解决方案在我的上下文中不起作用。在弄清楚“你的 RMarkdown 文件的 YAML front-matter”是什么之后,我解决了它。对于 bookdown,有一个 .travis.yml 文件和一个 _bookdown.yml 文件,但您想单独留下这两个文件,而这些不是错误消息所引用的内容。

“front-matter”将是您的 RMarkdown 文件的顶部(如果使用 bookdown 它将是“index.Rmd”文件),请参见下面的屏幕截图:

所以只需将 always_allow_html: yes 添加到 YAML header 作为它自己的行,它应该按预期工作(或者给你一个不同的错误)