问题
I use RMarkdown and knitr
for dynamic report generation.
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
... 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.
Does such an option exist with knitr
? Or is it possible to program this with a hook
in knitr
?
(using only include=FALSE
runs the code, but does not show the code.)
(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).
回答1:
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")
```
来源:https://stackoverflow.com/questions/42596609/knitr-chunk-option-eval-true-echo-true-include-false