在Ubuntu 14.04LTS上安装Pandoc时出现问题,无法与R Markdown一起使用

前端之家收集整理的这篇文章主要介绍了在Ubuntu 14.04LTS上安装Pandoc时出现问题,无法与R Markdown一起使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这个问题是我尝试通过knitr和rmarkdown R软件包从R Markdown文档创建可重现报告的一些经验的必然结果.虽然看起来像.Rmd => HTML转换是从RStudio(Knit HTML按钮)中自动完成的,我尝试在RStudio(Rscript -e’库(rmarkdown)之外做同样的事情; render(“knitr-example-slides-1.Rmd”)’)失败到期根据消息,我的系统缺乏pandoc.这很可能是错误的,因为RStudio以某种方式设法执行转换.因此,它很可能是访问和/或路径问题.

如果不知道RStudio维护pandoc的位置和访问细节,我决定自己安装pandoc.不幸的是,sudo apt-get install pandoc并不是很有帮助,因为Ubuntu可靠存储库(14.04LTS)中当前版本的pandoc是1.12.2.1.根据rmarkdown的消息,需要1.12.3或更高版本. “没什么大不了的”,我想,并且在存储库(http://johnmacfarlane.net/pandoc/installing.html)中版本太旧的情况下遵循安装pandoc的说明.这需要安装Haskell平台,这个平台非常大,输出相当冗长.过了一段时间,我终于遇到了以下失败消息:

  1. [ 6 of 57] Compiling Text.Pandoc.Readers.TeXMath ( src/Text/Pandoc/Readers/TeXMath.hs,dist/build/Text/Pandoc/Readers/TeXMath.o )
  2.  
  3. src/Text/Pandoc/Readers/TeXMath.hs:30:38:
  4. Ambiguous occurrence `readTeXMath'
  5. It could refer to either `Text.Pandoc.Readers.TeXMath.readTeXMath',defined at src/Text/Pandoc/Readers/TeXMath.hs:56:1
  6. or `Text.TeXMath.readTeXMath',imported from `Text.TeXMath' at src/Text/Pandoc/Readers/TeXMath.hs:33:1-19
  7. (and originally defined in `Text.TeXMath.Parser')
  8. Failed to install pandoc-1.12.4.2
  9. cabal: Error: some packages Failed to install:
  10. pandoc-1.12.4.2 Failed during the building phase. The exception was:
  11. ExitFailure 1
  12. pandoc-citeproc-0.3.1 depends on pandoc-1.12.4.2 which Failed to install.

首先,我不确定如何解决它.其次,我非常怀疑应该有一种更简单的方法来享受使用rmarkdown和pandoc生成可重现的报告.您的建议将不胜感激!

更新(见评论):

  1. Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
  2.  
  3.  
  4. processing file: knitr-example-slides-1.Rmd
  5. |....... | 11%
  6. ordinary text without R code
  7.  
  8. |.............. | 22%
  9. label: setup (with options)
  10. List of 1
  11. $include: logi FALSE
  12.  
  13. Quitting from lines 6-8 (knitr-example-slides-1.Rmd)
  14. Error in eval(expr,envir,enclos) : object 'opts_chunk' not found
  15. Calls: render ... handle -> withCallingHandlers -> withVisible -> eval -> eval
  16.  
  17. Execution halted
基本上,@ daroczig在上面的评论中回答了这个问题,所以我将在这里重复一遍,并在主要问题的问题修复后出现,并在相关的小问题上添加答案.

1)“Pandoc的二进制编译版本已经附带RStudio,因此您可以简单地创建一个符号链接,以便您可以轻松地在RStudio生态系统之外使用它:https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md#newer-systems-debianubuntufedora”;

2)我修复了错误,经过上面的建议(参见我的评论)后,通过使用显式包引用调用opts_chunk():knitr :: opts_chunk(),遵循以下指南:http://rmarkdown.rstudio.com/authoring_migrating_from_v1.html(感谢@Yihui指点我)在另一个问题中对本文件Transitioning research project to knitr-based setup).

猜你在找的Ubuntu相关文章