Skip to content

library( ) and verbose=

4 messages · Frank E Harrell Jr, Brian Ripley, Simon Urbanek +1 more

#
The Hmisc package has in its .First.lib function a verbose argument,
which I thought was the way to allow users to suppress certain messages,
by issuing library(Hmisc, verbose=FALSE).  But I see that library( )
does not pass verbose to .First.lib.  The default for verbose in Hmisc
is TRUE because .First.lib prints some important information about
masked functions.  What is the best way to fix this?  Is it reasonable
to expect library to pass verbose along?  I'm running R 1.9 on debian.
#
On Sun, 11 Jul 2004, Frank E Harrell Jr wrote:

            
No. It is not documented to, and .First.lib (in R or S) has only two 
documented arguments so it would not be possible to do this in a 
backwards-compatible way.  (If we passed ... along, then using
library(foo, verbose=FALSE) would fail for almost all packages foo with a 
.First.lib function.)

We normally suggest that such options are handled by setting an 
environment variable or perhaps an option (e.g. option(Hmisc.verbose = 
FALSE)).
#
On Jul 11, 2004, at 1:07 PM, Frank E Harrell Jr wrote:

            
AFAIR the official way to suppress unwanted messages is 
warn.conflicts=FALSE so the user probably wants to issue
library(Hmisc, warn.conflicts=FALSE).
As of 'verbose' - it is not by default TRUE - it's actually determined 
by the current "verbose" option, so users can actually change the 
default as desired.
On the other hand .First.lib takes only two, fixed arguments, so AFAIK 
you cannot pass any additional arguments from outside (I believe this 
applies to .onLoad and friends, too).
In fact I'm not quite sure what you want to "fix" here .. is it the 
wish in general to be able to pass arguments to packages while being 
loaded? In your specific case I'd say you don't need that since you 
have always access to the 'verbose' option ...

Simon
#
On Sun, Jul 11, 2004 at 04:23:10PM +0200, Simon Urbanek wrote:
Not bad, but note that Hmisc has a very explicit

    .First.lib <- function(lib, pkg, verbose=TRUE, ...) {
      if(verbose)
          cat("Hmisc library by Frank E Harrell Jr\n\n",
              "Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')\n",
	      [...]     
	      
so the additional option() Brian suggested way indeed be the best way.
I tried that several different ways before I brought this to Frank's
attention. No method worked; I ended up altering the R code in the installed
package to set the verbose=FALSE in the snipped shown above.
Quite so.

Dirk