次のファイルを編んでいます(eRRoR()
関数に注意してください):
\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}
Knitr をエラーで停止させたいです。ただし、stop_on_error=2L
オプションにもかかわらず、R の出力は次のようになります。
> 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
>
どうやら停止は発生していません。さらに、.tex 出力ファイルを PdfLaTeX すると、次の PDF スライドが得られます。
Test
eRRoR()
## Error:
could not find function "eRRoR"
message("aaa")
## aaa
print("test1")
## [1] "test1"
print("test2")
## [1] "test2"
スライドは、エラーにもかかわらず、編み物が続行することを確認します。
また、knitr が「R コードのない通常のテキスト」を出力する理由も (私には) 不明です。これらのチャンクには R コードがあります。また、出力によると、オプションmessage=FALSE
は有効ではないようです。
私は何を間違っていますか?ESS 12.09-1 [rev. 5167 (2012-09-24)] と Knitr_0.8 .