简体   繁体   English

knitr chunk选项eval = TRUE,echo = TRUE,include = FALSE

[英]knitr chunk option eval=TRUE, echo=TRUE, include=FALSE

I use RMarkdown and knitr for dynamic report generation. 我使用RMarkdown和knitr来生成动态报告。

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. 编织文档时,我想从编织文档中包含Rmarkdown块的代码并运行代码 - 但显示输出。 That is, I would like to be able to do what this code suggests: 也就是说,我希望能够执行此代码建议的内容:

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运行代码( eval = TRUE ),显示代码( echo = TRUE ),但不显示冗长的输出(尝试使用include = FALSE ),但我的尝试失败了。

Does such an option exist with knitr ? knitr有这样的选择吗? Or is it possible to program this with a hook in knitr ? 或者是否可以使用knitrhook对其进行编程?

(using only include=FALSE runs the code, but does not show the code.) (仅使用include=FALSE运行代码,但不显示代码。)

(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). (交叉发布的通知:我在一周前在RStudio支持上发布了这个问题,但没有收到任何答案,表明是或否,或者如何实现我想要的)。

If I am understanding your problem correctly, the issue is the include=F option. 如果我正确理解您的问题,问题是include=F选项。 You should try instead to use results = "hide" . 您应该尝试使用results = "hide" Here is how you can set it at the beginning of your Rmarkdown document so that it is the default setting. 以下是如何在Rmarkdown文档的开头设置它以使其成为默认设置。

```{r}
knitr::opts_chunk$set(eval = TRUE, echo = TRUE, results = "hide")
```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM