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

Shepherd, Lori Lor|@Shepherd @end|ng |rom Ro@we||P@rk@org
Wed Apr 24 19:29:40 CEST 2019


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]]



More information about the Bioc-devel mailing list