我正在重新安装knitr和LyX,并对我的新操作系统进行设置。我之前让它起作用了。我在Windows7企业版计算机上安装了最新版本的R (3.0.1)、Knitr版本1.3.3、包含MiKTex 2.9发行版的LyX 2.0.6和RStudio 0.97.551。如果我打开Lyx并简单地查看教程,就可以得到pdflatex输出,所以基本系统正在工作。
我试着运行我在Knitr上的旧LyX文件,但现在它们失败了。最初似乎存在路径问题,因为Rnw文件从未创建过。现在,在完成Rnw文件的创建后,它在转换为pdf时失败,如下面的错误所示。
15:34:23.619: Previewing ...
15:34:23.639: (buffer-view: Ctrl+R)
15:34:23.786: Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.Rnw" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.tex" ISO-8859-15 "C:/Users/tbrooks/Desktop/"
15:34:23.813: The system cannot find the path specified.
Running: Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.Rnw" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.tex" ISO-8859-15 "C:/Users/tbrooks/Desktop/"
..\..\..\src\support\Systemcall.cpp (273): Systemcall: 'Rscript --verbose --no-save --no- restore "C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.Rnw" "C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-minimal.tex" ISO-8859-15 "C:/Users/tbrooks/Desktop/"' finished with exit code 1
Error: Cannot convert file
----------------------------------------
An error occurred while running:
Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX
2.0/Resources/scripts/lyxknitr.R"
"C:/Users/tbrooks/AppData/Local/Temp/lyx_tmpdir.Hp6600/lyx_tmpbuf2/""knitr-m...
15:34:26.700: Error while previewing format: pdf2如果我使用下面两个链接的例子,它们都不能编译成LyX格式的PDF。如果我将Rnw文件带到R studio中,并尝试将其编译为pdf,它可以在 (link)中找到的knitr-intro.Rnw上工作,但当我尝试从LyX文件 (here)创建的knitr-minimal.Rnw时,在opts_chunk上失败。
任何帮助我们都将不胜感激。
更新:易辉的回答部分是有帮助的。
它解决了Rstudio的问题,通过更改为knitr。
它还部分解决了LyX问题。我在LyX中确实有一个到R的路径,实际上我有这个路径: C:\Program Files\R\R-3.0.1\bin,其中有R和R脚本可执行文件,但考虑到它是64位安装,我需要进一步深入到C:\Program Files\R\R-3.0.1\bin\x64。
我现在可以运行R块了,但是我仍然在编译一些示例时遇到了问题。我可以编译knitr-minimal.lyx,但不能编译knitr-graphics.lyx。我猜这可能与字体或tikzDevice有关。我会汇报的。谢谢
UPDATE2:事实上,tikzDevice不适用于R 3.0.1,所以这解释了演示失败的原因。在R中通过extrafonts将字体添加到我的文件中之后,我又回到了工作中。谢谢!
发布于 2013-07-19 07:17:54
从消息日志中,我猜是R is not in your PATH (also see here)。
对于RStudio的问题,我相信那是因为你没有选择knitr作为你的weaving method (默认情况下,它使用的是Sweave)。
https://stackoverflow.com/questions/17734135
复制相似问题