Sounds like you were using an old version of knitr
; see FAQ 1.
Knitting Beamer slides with Emacs-ESS (stop-on-error)
سؤال
I am knitting the following file (note the eRRoR()
function):
\documentclass{beamer}
<<setup, include=FALSE>>=
opts_knit$set(stop_on_error=2L, message=FALSE)
options(width=40)
@
\begin{document}
\begin{frame}[fragile]{Test}
<<test1>>=
eRRoR()
message("aaa")
print("test1")
@
<<test2>>=
print("test2")
@
\end{frame}
\end{document}
I’d like knitr to stop on error. But despite the stop_on_error=2L
option the R output is as follows:
> local({..od <- getwd(); setwd("c:/test/"); require(knitr); knit("c:/test/ktest.rnw"); setwd(..od) })
processing file: c:/test/ktest.rnw
|>>>>>>>>> | 14%
ordinary text without R code
|>>>>>>>>>>>>>>>>>>> | 29%
label: setup (with options)
List of 1
$ include: logi FALSE
|>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 43%
ordinary text without R code
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 57%
label: test1
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 71%
ordinary text without R code
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 86%
label: test2
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
ordinary text without R code
output file: c:\test\ktest.tex
>
Apparently stop does not occur. Besides, if I PdfLaTeX the .tex output file, I get the following PDF slide:
Test
eRRoR()
## Error:
could not find function "eRRoR"
message("aaa")
## aaa
print("test1")
## [1] "test1"
print("test2")
## [1] "test2"
The slide confirms that knitting goes on, despite the error.
It is also unclear (to me) why knitr prints “ordinary text without R code”. There is R code in those chunks.
Also, by the output, the option message=FALSE
doesn’t seem effective.
What am I doing wrong? I am using ESS 12.09-1 [rev. 5167 (2012-09-24)] and knitr_0.8 .
المحلول
لا تنتمي إلى StackOverflow