简体   繁体   English

r knit to pdf / html:pandoc文档转换失败,错误2

[英]r knit to pdf/html: pandoc document conversion failed with error 2

The R Markdown file seems to work in Rstudio. R Markdown文件似乎适用于Rstudio。 The r Markdown file can be converted into word, but not pdf/html.(Yesterday it gave different problem, so I change my question here.) Any help will be appreciated! r Markdown文件可以转换为单词,但不能转换为pdf / html。(昨天它给出了不同的问题,所以我在这里更改了我的问题。)任何帮助将不胜感激!

This is the context of my Markdown file: 这是我的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.

This is the outcome is I knit to html: 这是我编织到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

This is the outcome if I knit to pdf: 如果我编织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

A little background might help: 一点背景可能会有所帮助:

Pandoc is a Haskell binary (ie a distinct piece of non-R software), that is shipped with RStudio for sake of running RMarkdown conversion. Pandoc是一个Haskell二进制文件(即一个独特的非R软件),它与RStudio一起提供,以便运行RMarkdown转换。 It seems you are getting some deprecation warnings, like: 您似乎得到了一些弃用警告,例如:

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

This tells me you probably have an older version of RStudio, thus an older version of Pandoc. 这告诉我你可能有一个旧版本的RStudio,因此是旧版本的Pandoc。 You may want to reinstall RStudio to make sure you have the appropriate Pandoc version, then debug from there. 您可能需要重新安装RStudio以确保拥有适当的Pandoc版本,然后从那里进行调试。

Also, make sure to reinstall knitr and rmarkdown with the newest versions. 此外,请确保使用最新版本重新安装knitrrmarkdown

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM