Home > Back-end >  Turning off dplyr messages when using dplyr functions in your own packages in R
Turning off dplyr messages when using dplyr functions in your own packages in R

Time:03-29

I have written an R package that has a function that uses dplyr::group_by and dplyr::summarise. How do I ensure that users who use that function aren't subjected to the summarise() has grouped output by ‘X’. You can override using the .groups argument. message?

I can of course turn the message off by setting options(dplyr.summarise.inform = FALSE) but I would think this isn't good practice as it might turn off the options globally for anyone who loads the package. Is there a way I can turn off the message only for the function calls from my package?

CodePudding user response:

If we don't want to use options or .groups, can wrap with suppressMessages

library(dplyr)
suppressMessages(mtcars %>%
     group_by(cyl, vs) %>% 
     summarise(mpg = sum(mpg)))
  • Related