[Bioc-devel] How can I print a message on console with library("myPackage")?
Arman Shahrisa
@h@hr|@@@@rm@n @end|ng |rom hotm@||@com
Wed Apr 24 19:27:25 CEST 2019
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]]
More information about the Bioc-devel
mailing list