编织块选项eval = TRUE,echo = TRUE,include = FALSE [英] knitr chunk option eval=TRUE, echo=TRUE, include=FALSE

查看:487
本文介绍了编织块选项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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆