Question

I keep getting this error; Rscript --verbose --no-save --no-restore -- and I've seen others here get it too, so I don't hope it a duplicate.

I am just an 'average Joe' that want to learn some R and hopefully be able to report in lyx/knitr, therefore I don't understand much latex or coding in general.

That being said, I will try to describe the problem to my best ability.

I am able to compile some of the demos that are provided in the knitr folder, and some simple I've made my self. But for some reason the above mentioned error appears and the document is destroyed - meaning, even if I delete all code, I cannot compile it.

The error seems to almost appear at random, in the picture you can see the error. The first test went fine - although it has appeared when I use the hist() command -- this time it appeared when I tried to get the working directory, witch I've been able to do without error.

I'm not sure if it is a fault at my end or if it is a bug in Knitr/Lyx - hopefully you can help me determined whichever it is.

!! EDIT; Lyx-log as requested.

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

EDIT 2;

Do you mean this;

% Preview source code for paragraph 0


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

I've added a line between @ and <<test>>= and it now works. But I think I've seen it fail where I've had text between the code bits. I will beware of this and try to look at the source code in the future, thank you for your time !

Was it helpful?

Solution

My guess is you probably need a new line after the first @. I remember in certain cases LyX does not add a new line after the ERT (evil red text), and that will cause problems for knitr. I cannot say for sure when LyX will do that, because I rarely use Windows, and I cannot reproduce the problem under Ubuntu/LyX 2.0.6.

To verify, open the source panel from View-->View source, and see if there is a new line after @ in the LaTeX source.

It is always a good idea to open both the source panel and the message panel, to make sure you see everything behind LyX and know what was really wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top