Knitr を使用して、rnw ファイル内のコード ブロックに条件付き評価を使用したいと考えています。
公式の例を実行すると:knitr-examples/011-conditional-eval.Rnw
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<controller>>=
# this variable controls if a chunk should be evaluated
dothis <- TRUE
@
<<chunk1, eval = dothis>>=
print('say hello world')
@
<<chunk2, eval = !dothis>>=
print('silence is gold')
@
\end{document}
次のエラーが表示されます。
Writing to file test.tex
Processing code chunks with options ...
1 : echo keep.source term verbatim (label = controller, test.Rnw:6)
Error in check(options) : invalid value for 'eval' : dothis
Calls: <Anonymous> -> SweaveParseOptions -> check
Execution halted
私は何を間違っていますか?Rstudio を使用して rnw ファイルを実行しています