[Bioc-devel] How can I print a message on console with library("myPackage")?

Martin Morgan mtmorg@n@b|oc @end|ng |rom gm@||@com
Tue Apr 23 21:19:19 CEST 2019


This is called the 'tragedy of the commons', where everyone seems something that looks good (screen real-estate to advertise their package) and so takes advantage of it. Once everyone does that, the 'commons' is completely destroyed by messages like the one you're trying to suppress.

You can participate in this tragedy by using `packageStartupMessage()` in an `.onAttach()` or `.onLoad()` function, typically defined in R/zzz.R

.onAttach <- function(...) {
    packageStartupMessage("MY PACKAGE IS MORE IMPORTANT THAN YOUR PACKAGE!!")
}

As a developer you can't suppress messages from other packages (so you should make your message really big so that it can't be missed!). You can avoid Depend:ing or Import:ing packages that have messages, which might be a particularly good idea if the package provides minimal functionality for your own package.

The message below comes about because two packages R.oo and R.methodsS3 are both loaded directly or indirectly by your package, and they both define methods throw.default; this seems pretty strange to me, especially since both packages are written by the same person (who sometimes reads this list so might respond with a rational explanation)!

As a user you can 

    suppressPackageStartupMessages({
        library(...)
        library(...)
    }

Martin

On 4/23/19, 3:04 PM, "Bioc-devel on behalf of Arman Shahrisa" <bioc-devel-bounces using r-project.org on behalf of shahrisa.arman using hotmail.com> wrote:

    I�m the maintainer of package �cbaf�. I use roxygen2 for documentation.
    
    If I want a message to be printed when the user loads my package with library(), what should I do?
    
    
    I also have another question. When I load my package, a message is printed in console:
    
    > Registered S3 method overwritten by 'R.oo':
    >  method        from
    >  throw.default R.methodsS3
    
    How can I prevent this?
    
    
    
    
    
    Best regards,
    Arman
    
    
    	[[alternative HTML version deleted]]
    
    


More information about the Bioc-devel mailing list