[Rd] [External] Re: quiet namespace load is noisy
Lenth, Russell V
ru@@e||-|enth @end|ng |rom u|ow@@edu
Tue Jul 23 17:30:30 CEST 2019
Ben and Henrik,
My package tends to load other packages ‘ namespaces on an as-needed basis, e.g. ggplot2 when a plotting function is called. I have been thinking I would use suppressMessages() in my code, but it is probably a better idea to instead have a setup chunk in each vignette that loads all the needed namespaces or libraries. That way the package user would see those messages in their own session when they could be relevant.
Thanks
Russ
Sent from my iPhone
On Jul 23, 2019, at 9:28 AM, Henrik Singmann <singmann using gmail.com<mailto:singmann using gmail.com>> wrote:
Dear Russ,
I had the same problem in my vignettes and setting both message and warning to FALSE seems to remove all unwanted output:
```{r message=FALSE, warning=FALSE}
library("afex")
library("ggplot2")
library("cowplot")
theme_set(theme_grey())
```
Result: https://cran.r-project.org/web/packages/afex/vignettes/afex_plot_introduction.html
Best,
Henrik
Am Di., 23. Juli 2019 um 14:52 Uhr schrieb Ben Bolker <bbolker using gmail.com<mailto:bbolker using gmail.com>>:
Does setting message=FALSE in the chunk options of the vignette help?
Or less preferably, using supressMessages() ?
On 2019-07-23 9:36 a.m., Lenth, Russell V wrote:
> Lionel,
>
> Thanks for your response. I understand that method overriding can be a serious issue, but as you say, this is not something that the user can act upon. Yet the message lands at the user’s feet.
>
> In my case, the messages are cluttering my package vignettes, and may or may not represent what users see if they themselves run the vignette code, depending on what version of ggplot2, etc. they have. I will certainly update my ggplot2 installation and that will help. But basically I don’t ever want these kinds of messages to appear in my vignettes, so I will seek some other workaround.
>
> Russ
>
> Sent from my iPhone
>
>> On Jul 23, 2019, at 1:32 AM, Lionel Henry <lionel using rstudio.com<mailto:lionel using rstudio.com>> wrote:
>>
>> Hello,
>>
>> I think `quietly` should only silence normal masking messages
>> intended for users and providing information about normal
>> behaviour, such as masking. This is not the case here as the
>> message is about overriding of S3 methods, which has global
>> effect and is rather problematic. It may change behaviour of
>> package and script code in unpredictable ways.
>>
>> This is not something that the user can act upon, the developers
>> of the parties involved need to be contacted by users so they can
>> fix it (the developers of the conflicting methods might not be
>> aware if the generic is from a third party package, such as
>> base::print()). In the case of ggplot2 vs rlang, you can update
>> ggplot2 to the latest version to fix these messages.
>>
>>> After all, other package startup messages ARE suppressed, and
>>> even error messages are suppressed
>>
>> Note that `quietly = TRUE` does not really suppress error
>> messages for missing packages. The errors are converted to a
>> boolean return value, and thus become normal behaviour, for which
>> it makes sense to suppress the message. This does not imply the
>> S3 overriding message should be suppressed as well.
>>
>> Best,
>> Lionel
>>
>>
>>> On 23 Jul 2019, at 06:29, Lenth, Russell V <russell-lenth using uiowa.edu<mailto:russell-lenth using uiowa.edu>> wrote:
>>>
>>> Dear R-devel,
>>>
>>> Consider the following clip (in R version 3.6.0, Windows):
>>>
>>>> requireNamespace("ggplot2", quietly = TRUE)
>>> Registered S3 methods overwritten by 'ggplot2':
>>> method from
>>> [.quosures rlang
>>> c.quosures rlang
>>> print.quosures rlang
>>>
>>> It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:
>>>
>>>> requireNamespace("xyz", quietly = TRUE)
>>>> ## (it is silent even though there is no "xyz" package)
>>>
>>> Thanks
>>>
>>> Russ Lenth
>>> U of Iowa
>>>
>>> ______________________________________________
>>> R-devel using r-project.org<mailto:R-devel using r-project.org> mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> ______________________________________________
> R-devel using r-project.org<mailto:R-devel using r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
______________________________________________
R-devel using r-project.org<mailto:R-devel using r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Dr. Henrik Singmann
Assistant Professor, Department of Psychology
University of Warwick, UK
http://singmann.org
[[alternative HTML version deleted]]
More information about the R-devel
mailing list