0

I'm running a command in a function and I'd like to silence the output.

In particular, there's these two outputs that I'd like to silence

summarise()` ungrouping output (override with `.groups` argument)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

One happens when I use group_by() %>% summarize() and the second happens when I use geom_histogram(). They're not warnings, so I don't think suppressWarnings will work.

tadon11Aaa
  • 400
  • 2
  • 11

1 Answers1

1

You can set bins manually to override that message from being displayed regarding geom_histogram.

To avoid message from summarise use .groups == 'keep' as mentioned by @ LC-datascientist or use suppressMessages.

library(dplyr)
library(ggplot2)

suppressMessages(mtcars %>%
  group_by(cyl, am) %>%
  summarise(mpg = sum(mpg)) %>%
  ggplot() + aes(am) + geom_histogram(bins = 10))
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213