【问题标题】:r knit to pdf/html: pandoc document conversion failed with error 2r knit to pdf/html: pandoc 文档转换失败,错误 2
【发布时间】:2018-09-07 19:55:58
【问题描述】:

R Markdown 文件似乎可以在 Rstudio 中使用。 r Markdown文件可以转换为word,但不能转换为pdf/html。(昨天它给出了不同的问题,所以我在这里改变了我的问题。) 任何帮助将不胜感激!

这是我的 Markdown 文件的上下文:

---
title: "Test"
author: "Test"
date: "2018/9/8"
output: html_document
---
## R test

```{r test}
x<-rnorm(500)
y<-rnorm(x*10)
ls()
plot(x,y)
rm(x,y)
```

This is an test.

这是我编织到 html 的结果:

 |......................                                           |  33%
  ordinary text without R code



processing file: test.Rmd
  |...........................................                      |  67%
label: test
  |.................................................................| 100%
  ordinary text without R code
/usr/local/bin/pandoc +RTS -K512m -RTS test.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/_h/013l11r91m3gny4lqwsvh5qh0000gn/T//Rtmpfvxqld/rmarkdown-str268664475eb.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' 
output file: test.knit.md

--smart/-S has been removed.  Use +smart or -smart extension instead.
For example: pandoc -f markdown+smart -t markdown-smart.
Try pandoc --help for more information.
error: pandoc document conversion failed with error 2
stop processing

这就是我编织成 pdf 的结果:

|......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: test


processing file: test.Rmd
  |.................................................................| 100%
  ordinary text without R code

    /usr/local/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine /Library/TeX/texbin/pdflatex --variable graphics=yes --variable 'geometry:margin=1in' 
    output file: test.knit.md

    --latex-engine has been removed.  Use --pdf-engine instead.
    Try pandoc --help for more information.
    error: pandoc document conversion failed with error 2
    stop processing

【问题讨论】:

  • 您需要向我们展示您的源代码(简化版)。
  • 回复user2554330:我今天又试了,r studio给了我不同的错误。在这里,我添加了我的脚本(简化版)。谢谢提醒。
  • 来自pandoc 的错误消息表明您使用的是不兼容的版本和knitrrmarkdown。也许更新 RStudio 和所有软件包?
  • When in doubt, upgrade. 我很确定您使用的是旧版本的 rmarkdown。这个问题已于去年修复。我建议您在询问有关 R 包的问题时始终提供sessionInfo()
  • 为我击败一辉而感到自豪哈哈

标签: r r-markdown knitr pandoc


【解决方案1】:

一点背景知识可能会有所帮助:

Pandoc 是一个 Haskell 二进制文件(即一个独特的非 R 软件),它随 RStudio 一起提供,用于运行 RMarkdown 转换。您似乎收到了一些弃用警告,例如:

  • --latex-engine has been removed. Use --pdf-engine instead.
  • --smart/-S has been removed. Use +smart or -smart extension instead.

这告诉我你可能有一个旧版本的 RStudio,因此是一个旧版本的 Pandoc。您可能需要重新安装 RStudio 以确保您拥有适当的 Pandoc 版本,然后从那里进行调试。

另外,请务必使用最新版本重新安装 knitrrmarkdown

【讨论】:

  • 最后一个小提示:“另外,请确保使用最新版本重新安装 knitrrmarkdown。”非常重要(并且 RStudio)应该警告您这些软件包已过时....
猜你喜欢
  • 2017-07-14
  • 1970-01-01
  • 2016-04-13
  • 1970-01-01
  • 2015-01-14
  • 2018-02-23
  • 2017-05-08
  • 2019-10-14
  • 2020-02-22
相关资源
最近更新 更多