tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.

Home Page:https://reprex.tidyverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suppress package startup messages automatically

olivroy opened this issue · comments

I wonder if there was an option to suppress these types of messages automatically, either via an option that can be put in .Rprofile.
maybe :

options(reprex.startup = FALSE) 

or reprex::reprex(startup = FALSE)
I agree other warnings are useful, but these are really useless. It is also annoying and ugly to put suppressPackageStartupMessages() all the time.

library(tidyverse)
#> Warning: le package 'tidyverse' a été compilé avec la version R 4.1.1
#> Warning: le package 'ggplot2' a été compilé avec la version R 4.1.3
#> Warning: le package 'tibble' a été compilé avec la version R 4.1.3
#> Warning: le package 'tidyr' a été compilé avec la version R 4.1.2
#> Warning: le package 'readr' a été compilé avec la version R 4.1.2
#> Warning: le package 'purrr' a été compilé avec la version R 4.1.1
#> Warning: le package 'stringr' a été compilé avec la version R 4.1.1
library(sf)
#> Warning: le package 'sf' a été compilé avec la version R 4.1.2
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE

Created on 2022-06-17 by the reprex package (v2.0.1)

By default, reprex does suppress the start messages for tidyverse packages:

library(tidyverse)

Created on 2022-06-20 by the reprex package (v2.0.1.9000)

So it you get different behaviour, something in your setup, e.g. in .Rprofile, must be interfering with that.

You can read more about the reprex.tidyverse_quiet option in the docs:

https://reprex.tidyverse.org/reference/reprex_options.html

I can't suppress startup messages in general because they aren't generally thrown with a class that allows selective suppression. I can do it for the tidyverse (and tidymodels) because tidyverse and tidymodels make this configurable.