Re: [Rd] Wishlist: 'quietly' argument for .onAttach() / .First.li b()

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Thu 13 Apr 2006 - 19:58:07 GMT

>>>>> "AndyL" == Liaw, Andy <andy_liaw@merck.com> >>>>> on Thu, 13 Apr 2006 15:41:27 -0400 writes:

    AndyL> From: Bill Dunlap
>> On Thu, 13 Apr 2006, Prof Brian Ripley wrote:
>>
>> > On Thu, 13 Apr 2006, Peter Ruckdeschel wrote:
>> >
>> > > Hi R-devels,
>> > >
>> > > in "Writing R extensions" as well as in the help > >
>> to .onAttach(), you mention that one could > > use this
>> function to issue a start-up message/banner > > for the
>> package.
>> > >
>> > > My little wish for Easter:
>> > >
>> > > a 'quietly'-type argument for .onAttach() /
>> .First.lib() which is > > passed through by functions > >
>> require() and library() respectively, > > and by means of
>> which one could optionally > > suppress this start-up
>> message/banner .
>> > >
>> > > Is this hard to do?
>> >
>> > I believe so (and think we have been here before). The
>> documented > call sequence is
>> >
>> > .onLoad(libname, pkgname) > .onAttach(libname, pkgname)
>> >
>> > the same as .First.lib. There is no way to add an
>> argument here, as > many existing packages do not support
>> it. Beyond that, how would you > pass the argument in?
>> Namespaces and packages are often > loaded/attached
>> implicitly as a result of loading other packages.
>> >
>> > I did think you could make use of an option to decide
>> whether to the > print the message or not, but I have
>> always assumed that those who did > want a banner
>> probably did not want it suppressed.
>>
>> If the .onAttach() used message() instead of cat() to
>> display the banner message then you could use
>> suppressMessages(require("randomForest")) to squelch the
>> message.

Very nice thought and proposal!

    AndyL> Thanks! This looks like a good alternative. What do     AndyL> others think of this approach?

I think we should recommend to use message(.) instead of cat(.) inside in .onAttach() or .First.lib() functions.

Martin

>> ---------------------------------------------------------------------
>> Bill Dunlap Insightful Corporation bill at insightful dot
>> com 360-428-8146
>>
>> "All statements in this message represent the opinions of
>> the author and do not necessarily reflect Insightful
>> Corporation policy or position."



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Apr 14 06:36:32 2006

This archive was generated by hypermail 2.1.8 : Thu 13 Apr 2006 - 22:17:39 GMT