[Bioc-devel] best practice: verbose messages
On Wed, Jul 10, 2013 at 9:10 PM, Herv? Pag?s <hpages at fhcrc.org> wrote:
Hi Kasper, On 07/10/2013 10:50 AM, Kasper Daniel Hansen wrote:
On Wed, Jul 10, 2013 at 12:38 PM, Dan Tenenbaum <dtenenba at fhcrc.org> wrote:
On Wed, Jul 10, 2013 at 9:17 AM, Michael Lawrence <lawrence.michael at gene.com> wrote:
If it's an informational message, like one you might log, use message().
If
you're rendering an object as text, like in a show method, use cat().
Another thing to consider is that messages can be suppressed with suppressMessages() but cat() output cannot.
Sure. What I cannot decide is whether that is good or bad.
If you use message(), then you don't need to have a 'verbose' arg since the messages can be suppressed with suppressMessages(). That makes your code simpler/cleaner. However this approach is only appropriate if you want your function to be verbose by default. If you want it to be quiet by default then I don't know what's best. 'verbose' arg + cat() or 'verbose' arg + message() ? That's the question...
You can also imagine different amounts of verbose, so not always TRUE or FALSE. About Kasper's original question, I'd also say use message(). I've recently done this transition in several of my packages (mostly via the Verbose class in R.utils). I've thought about this for a long time, but what made me do the transition is the fact that many of the literate programming tools in R echoes the standard output in code chunks, but not the standard errors. I don't want my verbose/log messages to be displayed in reports/vignettes (by default). /Henrik
H.
Kasper
Dan
Just my opinion, Michael On Wed, Jul 10, 2013 at 8:24 AM, Kasper Daniel Hansen < kasperdanielhansen at gmail.com> wrote:
Should I use cat() or message() (or something else) for
if(verbose) cat("my message\n")
Best,
Kasper
[[alternative HTML version deleted]]
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
[[alternative HTML version deleted]]
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
[[alternative HTML version deleted]]
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
-- Herv? Pag?s Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel