Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide messages from ggplot in knitr

Tags:

r

ggplot2

knitr

I'm using RStudio to knit my R markdown document into a word file.

I have this chunk in the beginning of my document:

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

But, I still keep have these messages inside my document after an histogram:

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

How can I make them go away?

like image 781
zelite Avatar asked Dec 05 '22 00:12

zelite


2 Answers

For this particular message, you can make it disappear by specifying the binwidth argument to geom_histogram. This is good practise, so you should do it!

In general, you can suppress messages by setting message = FALSE as a chunk option.

like image 196
Richie Cotton Avatar answered Dec 15 '22 00:12

Richie Cotton


The option to suppress this is now

, warning = F
like image 26
nzcoops Avatar answered Dec 14 '22 23:12

nzcoops