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

Martin Morgan mtmorg@n@b|oc @end|ng |rom gm@||@com
Wed Apr 24 21:10:30 CEST 2019


Yes I strongly second Robert's suggestion.

Also be sure that you are registered at https://support.bioconductor.org and that you enter your package name in the 'Watched tags' field of the user Profile, so that you are notified by email whenever a question is posted there.

Martin

On 4/24/19, 2:48 PM, "Bioc-devel on behalf of Robert M. Flight" <bioc-devel-bounces using r-project.org on behalf of rflight79 using gmail.com> wrote:

    Instead of putting the message in the startup, perhaps make use of
    the BugReports field in the package DESCRIPTION, and maybe use a GitHub
    issues page with a good template ....
    
    This way you avoid annoying your users with startup messages, for something
    that should be accessible in the DESCRIPTION itself.
    
    -Robert
    
    On Wed, Apr 24, 2019 at 2:08 PM Arman Shahrisa <shahrisa.arman using hotmail.com>
    wrote:
    
    > Thank you very much for your kind help. That fixed my issue.
    >
    >
    > Best regards,
    > Arman
    >
    > ________________________________
    > From: Shepherd, Lori <Lori.Shepherd using RoswellPark.org>
    > Sent: Wednesday, April 24, 2019 9:59:40 PM
    > To: Arman Shahrisa; Martin Morgan; bioc-devel; szwjf08 using gmail.com
    > Subject: Re: [Bioc-devel] How can I print a message on console with
    > library("myPackage")?
    >
    >
    > I assume your package is the cbaf package?
    >
    > Don't forget the new zzz.R file to the collate field in the DESCRIPTION
    >
    >
    > Lori Shepherd
    >
    > Bioconductor Core Team
    >
    > Roswell Park Cancer Institute
    >
    > Department of Biostatistics & Bioinformatics
    >
    > Elm & Carlton Streets
    >
    > Buffalo, New York 14263
    >
    > ________________________________
    > From: Bioc-devel <bioc-devel-bounces using r-project.org> on behalf of Arman
    > Shahrisa <shahrisa.arman using hotmail.com>
    > Sent: Wednesday, April 24, 2019 1:27:25 PM
    > To: Martin Morgan; bioc-devel; szwjf08 using gmail.com
    > Subject: Re: [Bioc-devel] How can I print a message on console with
    > library("myPackage")?
    >
    > I really appreciate your kind answers. I created the zzz.R file in the
    > same folder as the rest
    >
    > of my R files. I tried both .onAttach and .onLoad functions as follow:
    >
    >
    >
    >
    >
    > >  .onAttach <- function(libname, pkgname){
    >
    > >    packageStartupMessage("Please send bug reports and suggestions to
    > shahrisa.arman using hotmail.com with a meaningful email subject")
    >
    > >  }
    >
    >
    >
    >
    >
    > When I use Install and Restart in Rstudio, I get the following error:
    >
    >
    >
    >
    >
    > ==> Rcmd.exe INSTALL --no-multiarch --with-keep.source cbaf
    >
    >
    >
    > * installing to library 'C:/Program Files/R/R-devel/library'
    >
    > * installing *source* package 'cbaf' ...
    >
    > ** R
    >
    > Error in .install_package_code_files(".", instdir) :
    >
    > files in 'Z:/cbaf/Source/cbaf/R' missing from 'Collate' field:
    >
    >   zzz.R
    >
    > ERROR: unable to collate and parse R files for package 'cbaf'
    >
    > * removing 'C:/Program Files/R/R-devel/library/cbaf'
    >
    > * restoring previous 'C:/Program Files/R/R-devel/library/cbaf'
    >
    >
    >
    > Exited with status 1.
    >
    >
    >
    >
    >
    >
    >
    > Best regards,
    > Arman
    >
    >
    >
    > ________________________________
    > From: Martin Morgan <mtmorgan.bioc using gmail.com>
    > Sent: Tuesday, April 23, 2019 11:49:19 PM
    > To: Arman Shahrisa; bioc-devel
    > Subject: Re: [Bioc-devel] How can I print a message on console with
    > library("myPackage")?
    >
    > 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]]
    >
    >
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > Bioc-devel using r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/bioc-devel
    >
    > This email message may contain legally privileged and/or confidential
    > information. If you are not the intended recipient(s), or the employee or
    > agent responsible for the delivery of this message to the intended
    > recipient(s), you are hereby notified that any disclosure, copying,
    > distribution, or use of this email message is prohibited. If you have
    > received this message in error, please notify the sender immediately by
    > e-mail and delete this email message from your computer. Thank you.
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > Bioc-devel using r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/bioc-devel
    >
    
    	[[alternative HTML version deleted]]
    
    _______________________________________________
    Bioc-devel using r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/bioc-devel
    


More information about the Bioc-devel mailing list