这个问题是我尝试通过和R 包从文档创建可重现报告方面获得一些经验的必然结果。虽然看起来转换是在 RStudio(按钮)内自动进行的,但我尝试在 RStudio()之外执行相同操作却失败了,因为根据消息,我的系统上没有。这很可能是错误的,因为 RStudio 以某种方式设法执行了转换。因此,很可能是访问和/或路径问题。R Markdown
knitr
rmarkdown
.Rmd => HTML
Knit HTML
Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
pandoc
在不知道 RStudio 维护的位置pandoc
和访问权限的详细信息的情况下,我决定自己安装 pandoc
。不幸的是sudo apt-get install pandoc
,由于pandoc
Ubuntutrusty
存储库 (14.04LTS) 中的当前版本是 1.12.2.1,因此并没有太大帮助。根据rmarkdown
's message,需要 1.12.3 或更高版本。“没什么大不了的”,我想,并按照说明安装pandoc
,以防存储库中的版本太旧(http://johnmacfarlane.net/pandoc/installing.html)。这需要安装Haskell 平台,这个平台很大,输出也很冗长。一段时间后,我终于收到了以下失败消息:
[ 6 of 57] Compiling Text.Pandoc.Readers.TeXMath ( src/Text/Pandoc/Readers/TeXMath.hs, dist/build/Text/Pandoc/Readers/TeXMath.o )
src/Text/Pandoc/Readers/TeXMath.hs:30:38:
Ambiguous occurrence `readTeXMath'
It could refer to either `Text.Pandoc.Readers.TeXMath.readTeXMath',
defined at src/Text/Pandoc/Readers/TeXMath.hs:56:1
or `Text.TeXMath.readTeXMath',
imported from `Text.TeXMath' at src/Text/Pandoc/Readers/TeXMath.hs:33:1-19
(and originally defined in `Text.TeXMath.Parser')
Failed to install pandoc-1.12.4.2
cabal: Error: some packages failed to install:
pandoc-1.12.4.2 failed during the building phase. The exception was:
ExitFailure 1
pandoc-citeproc-0.3.1 depends on pandoc-1.12.4.2 which failed to install.
首先,我不确定如何解决它。其次,我非常怀疑应该有比这更简单的方法来享受生成可重复的报告。您的建议将不胜感激!rmarkdown
pandoc
更新(见评论):
Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
processing file: knitr-example-slides-1.Rmd
|....... | 11%
ordinary text without R code
|.............. | 22%
label: setup (with options)
List of 1
$ include: logi FALSE
Quitting from lines 6-8 (knitr-example-slides-1.Rmd)
Error in eval(expr, envir, enclos) : object 'opts_chunk' not found
Calls: render ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted