Suppressing a warning from library()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Suppressing a warning from library()

Therneau, Terry M., Ph.D.
I get a warning about "1 warning message" using R CMD check on the
survival library.  It comes from the code snippet:

   if (library(cmprsk, logical.return=TRUE)) {
        # further test of competing risks from survfit
        .
        .
        }
This is a very useful additional test when I'm checking any changes to
the affected code, so I like having this in my test suite even though it
doesn't run automatically.  

This argues for a change in library -- when the user sets logical.return
=T they don't need a warning message too.  I submit this to the R core
and their collective wisdom.

I admit that mine is an unusual case, and for now I'll turn if off with
options(warn=-1)

Terry T.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing a warning from library()

Peter Dalgaard
Terry Therneau wrote:

> I get a warning about "1 warning message" using R CMD check on the
> survival library.  It comes from the code snippet:
>
>    if (library(cmprsk, logical.return=TRUE)) {
> # further test of competing risks from survfit
> .
> .
> }
> This is a very useful additional test when I'm checking any changes to
> the affected code, so I like having this in my test suite even though it
> doesn't run automatically.  
>
> This argues for a change in library -- when the user sets logical.return
> =T they don't need a warning message too.  I submit this to the R core
> and their collective wisdom.
>
> I admit that mine is an unusual case, and for now I'll turn if off with
> options(warn=-1)

Probably, wrapping in suppressWarnings() is better.

-p


--
    O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])              FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing a warning from library()

Prof Brian Ripley
In reply to this post by Therneau, Terry M., Ph.D.
On Wed, 24 Feb 2010, Terry Therneau wrote:

> I get a warning about "1 warning message" using R CMD check on the
> survival library.  It comes from the code snippet:
>
>   if (library(cmprsk, logical.return=TRUE)) {
> # further test of competing risks from survfit
> .
> .
> }
> This is a very useful additional test when I'm checking any changes to
> the affected code, so I like having this in my test suite even though it
> doesn't run automatically.
>
> This argues for a change in library -- when the user sets logical.return
> =T they don't need a warning message too.

It was the considered opinion that in general they do.  You can always
use suppressWarnings() in your code if you don't, or you can pre-check
that the package is available via lower-level functions such as
.packages and .find.package.

> I submit this to the R core and their collective wisdom.
>
> I admit that mine is an unusual case, and for now I'll turn if off with
> options(warn=-1)
>
> Terry T.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing a warning from library()

Therneau, Terry M., Ph.D.
The suppressWarnings construct looks like a good idea; I was not aware
of it's existence.

Thanks for the feedback.

        Terry T.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel