Pregunta

I'm working on getting knitr and LyX re-installed and working on my fresh OS setup. I had it working previously. I installed the latest version of R (3.0.1), Knitr is ver 1.3.3, LyX 2.0.6 including the MiKTex 2.9 distribution, and RStudio 0.97.551 on a Windows 7 Enterprise computer. I can get pdflatex output if I open up Lyx and simply view the tutorial, so the basic system is working.

I've tried running old LyX files I had with Knitr, but now they fail. Initially there appeared to be a path issue, as the Rnw file was never created. Now it fails on converting to pdf as in the errors below, having completed the creation of the Rnw file.

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

If I use two examples linked below from Yihui Xie they both fail to compile to PDF in LyX. If I bring the Rnw file into R studio and try to compile it to pdf, it works for the knitr-intro.Rnw found here (link), but fails on the opts_chunk when I try knitr-minimal.Rnw created from the LyX file (here).

Any help would be thoroughly appreciated

UPDATE: Yihui's answer below is partially helpful.

It solved the Rstudio issue, by changing to knitr.

It also partially solved the LyX issue. I did have a path to R in LyX, in fact I had this path: C:\Program Files\R\R-3.0.1\bin where there are R and Rscript executables, but given it is a 64 bit install i needed to go one further down to C:\Program Files\R\R-3.0.1\bin\x64.

I can now run R chunks, however I am still having trouble compiling some of the examples. I can compile knitr-minimal.lyx, but not knitr-graphics.lyx. I'm guessing this might have something to do with font or the tikzDevice. I will report back. Thanks

UPDATE2: In fact tikzDevice is not available for R 3.0.1, so that explains the failure of that demo. After adding the fonts in my file through extrafonts in R, I'm back in business. Thanks!

¿Fue útil?

Solución

From the message log, I guess R is not in your PATH (also see here).

For the problem with RStudio, I believe that is because you did not select knitr as your weaving method (by default it uses Sweave).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top