首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在rnw文件中使用Knitr进行条件求值

如何在rnw文件中使用Knitr进行条件求值
EN

Stack Overflow用户
提问于 2016-05-27 07:29:56
回答 1查看 235关注 0票数 0

我想要对rnw文件中的代码块使用conditional eval。

当我运行官方示例时:knitr examples/011-conditional-eval.Rnw

代码语言:javascript
复制
\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}

我得到以下错误:

代码语言:javascript
复制
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文件

EN

回答 1

Stack Overflow用户

发布于 2016-05-27 19:01:06

你看起来是在运行Sweave,而不是knitr。在RStudio中检查您的全局或项目选项,看看它选择了哪一个。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37472619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档