2

我不断收到此错误;Rscript --verbose --no-save --no-restore- 我在这里看到其他人也得到它,所以我不希望它重复。

我只是一个想要学习一些 R 并希望能够在 lyx/knitr 中报告的“普通乔”,因此我一般不太了解乳胶或编码。

话虽如此,我会尽力描述这个问题。

我能够编译 knitr 文件夹中提供的一些演示,以及一些我自己制作的简单演示。但是由于某种原因,出现了上述错误并且文档被破坏 - 这意味着即使我删除了所有代码,我也无法编译它。

错误似乎几乎是随机出现的,在图片中您可以看到错误。第一次测试很顺利——虽然它在我使用 hist() 命令时出现了——这次它出现在我试图获取工作目录时,我已经能够做到没有错误。

我不确定这是我的错误还是 Knitr/Lyx 中的错误 - 希望您能帮助我确定是哪一个。

!!编辑; Lyx-log 按要求。

22:47:42.732: Previewing ...
22:47:42.739: (buffer-view: Ctrl+R)
22:47:42.779: Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R" "C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.Rnw" "C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.tex" ISO-8859-15 "C:/Users/Toddi/Documents/"
Running: Rscript --verbose --no-save --no-restore "C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R" "C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.Rnw" "C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.tex" ISO-8859-15 "C:/Users/Toddi/Documents/"
22:47:43.408: 
  |                                                                       
  |                                                                 |   0%
  |                                             
22:47:43.409:                           
  |......................                                           |  33%
22:47:43.409:   ordinary text without R code
22:47:43.409: 
22:47:43.409: 
  |                                                                       
  |...........................................                      |  67%
22:47:43.409: label: test
22:47:43.410: running
22:47:43.410:   'C:\PROGRA~1\R\R-30~1.1\bin\i386\Rterm.exe --slave --no-restore --no-save --no-restore --file=C:/Program Files (x86)/LyX 2.0/Resources/scripts/lyxknitr.R --args C:/Users/Toddi/AppData/Local/Temp/ly
22:47:43.410: x_tmpdir.Hp4668/lyx_tmpbuf2/newfile1.Rnw C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/newfile1.tex ISO-8859-15'
22:47:43.411: 
22:47:43.411: 
22:47:43.411: 
22:47:43.411: processing file: C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/newfile1.Rnw
22:47:43.456: 
22:47:43.457: Advarsel i block_exec(params) :
22:47:43.457:   failed to tidy R code in chunk <test>
22:47:43.459: reason: Error in base::parse(text = text, srcfile = NULL) : 3:1: unexpected '@'
22:47:43.459: 2: hist(q)
22:47:43.459: 3: @
22:47:43.460:   ^
22:47:43.460: 
22:47:43.460: Quitting from lines 11-15 (C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/newfile1.Rnw) 
22:47:43.461: Fejl i parse(text = x, srcfile = src) : <text>:3:1: unexpected '@'
22:47:43.461: 2: hist(q)
22:47:43.461: 3: @
22:47:43.461:   ^
22:47:43.461: Calls: knit ... evaluate -> parse_all -> parse_all.character -> parse
22:47:43.461: Execution halted
..\..\..\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/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.Rnw" "C:/Users/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1.tex" ISO-8859-15 "C:/Users/Toddi/Documents/"' 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/Toddi/AppData/Local/Temp/lyx_tmpdir.Hp4668/lyx_tmpbuf2/""newfile1....
22:51:00.499: Automatic save done.
22:51:51.362: Error while previewing format: pdf2

编辑2;

你是这个意思吗?

% Preview source code for paragraph 0


<<test>>=
q <- rnorm(100)
hist(q)
@<<test2>>=
getwd()
@

我在@and之间添加了一条线<<test>>=,它现在可以工作了。但我想我已经看到它在代码位之间有文本的地方失败了。我会注意这一点,以后会尝试查看源代码,谢谢您的时间!

4

1 回答 1

2

我的猜测是您可能需要在第一个@. 我记得在某些情况下,LyX 不会在ERT(邪恶的红色文本)之后添加新行,这会导致knitr. 我不能确定 LyX 什么时候会这样做,因为我很少使用 Windows,而且我无法在 Ubuntu/LyX 2.0.6 下重现该问题。

要进行验证,请从 中打开源代码面板View-->View source,查看 LaTeX 源代码后面是否有新行@

打开源面板和消息面板总是一个好主意,以确保您看到 LyX 背后的所有内容并知道真正的错误。

于 2013-07-27T02:13:28.840 回答