如何在knitr中隐藏来自ggplot的消息

zel*_*ite 1 r ggplot2 knitr

我正在使用RStudio将我的R markdown文档编织成一个word文件.

我在文档的开头有这个块:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warnings=FALSE, messages=FALSE, results="hide")
``` 
Run Code Online (Sandbox Code Playgroud)

但是,在直方图之后我仍然在我的文档中保留这些消息:

## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 686 rows containing non-finite values (stat_bin).
Run Code Online (Sandbox Code Playgroud)

我怎么能让它们消失?

Ric*_*ton 8

对于此特定消息,您可以通过指定binwidth参数来使其消失geom_histogram.这是一个很好的做法,所以你应该这样做!

通常,您可以通过设置message = FALSE块选项来禁止消息.