R markdown编译错误:

wol*_*oor 2 r rstudio knitr r-markdown

当我尝试将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.
Run Code Online (Sandbox Code Playgroud)

有人知道这意味着什么吗?

Ric*_*cky 11

我在使用 Bookdown 时遇到了这个问题,并且接受的解决方案在我的上下文中不起作用。在弄清楚“您的 RMarkdown 文件的 YAML 前端问题”是什么之后,我解决了这个问题。使用 bookdown,有一个 .travis.yml 文件和一个 _bookdown.yml 文件,但是您想单独保留这两个文件,并且这些不是错误消息所引用的内容。

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

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


Gor*_*rka 5

您是否尝试过以下方法?(从:https : //bookdown.org/yihui/bookdown/html-widgets.html

install.packages("webshot")
webshot::install_phantomjs()
Run Code Online (Sandbox Code Playgroud)

它为我工作。另请参阅:https : //github.com/rstudio/bookdown/issues/440