编织块选项eval = TRUE,echo = TRUE,include = FALSE [英] knitr chunk option eval=TRUE, echo=TRUE, include=FALSE
问题描述
我使用RMarkdown和knitr
来动态生成报告.
I use RMarkdown and knitr
for dynamic report generation.
编织文档时,我希望将Rmarkdown块中的代码包含在编织文档中并运行代码-但 not 不显示输出.也就是说,我希望能够执行以下代码建议的操作:
When knitting a document, I would like to have the code from an Rmarkdown chunk included in the knitted document and run the code -- but not show the output. That is, I would like to be able to do what this code suggests:
eval=TRUE, echo=TRUE, include=FALSE
...并使knitr
运行代码(eval = TRUE
),显示代码(echo = TRUE
),但不显示冗长的输出(尝试使用include = FALSE
),但我的尝试失败.
... and make knitr
run the code (eval = TRUE
), show the code (echo = TRUE
), but not show the lengthy output (attempted with include = FALSE
), but my attempts fail.
knitr
是否存在这样的选项?还是可以用knitr
中的hook
对此进行编程?
Does such an option exist with knitr
? Or is it possible to program this with a hook
in knitr
?
(仅使用include=FALSE
运行代码,但不显示代码.)
(using only include=FALSE
runs the code, but does not show the code.)
(交叉发布的通知:我在一个星期前在RStudio支持人员上发布了此问题,但未收到任何表示是或否或如何实现我想要的答案).
(Notification of cross-posting: I posted this question at RStudio support a week ago, but have not received any answer indicating yes or no, or how to achieve what I want).
推荐答案
如果我正确理解了您的问题,则问题是include=F
选项.您应该尝试使用results = "hide"
.您可以在Rmarkdown文档的开头设置此设置,以使其成为默认设置.
If I am understanding your problem correctly, the issue is the include=F
option. You should try instead to use results = "hide"
. Here is how you can set it at the beginning of your Rmarkdown document so that it is the default setting.
```{r}
knitr::opts_chunk$set(eval = TRUE, echo = TRUE, results = "hide")
```
这篇关于编织块选项eval = TRUE,echo = TRUE,include = FALSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!