From hpages at fredhutch.org  Wed May  3 02:50:12 2017
From: hpages at fredhutch.org (=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=)
Date: Tue, 2 May 2017 17:50:12 -0700
Subject: [Rd] stopifnot() does not stop at first non-TRUE argument
Message-ID: <64acdaeb-2857-9017-68c9-9da08e29a617@fredhutch.org>

Hi,

It's surprising that stopifnot() keeps evaluating its arguments after
it reaches the first one that is not TRUE:

   > stopifnot(3 == 5, as.integer(2^32), a <- 12)
   Error: 3 == 5 is not TRUE
   In addition: Warning message:
   In stopifnot(3 == 5, as.integer(2^32), a <- 12) :
     NAs introduced by coercion to integer range
   > a
   [1] 12

The details section in its man page actually suggests that it should
stop at the first non-TRUE argument:

   ?stopifnot(A, B)? is conceptually equivalent to

    { if(any(is.na(A)) || !all(A)) stop(...);
      if(any(is.na(B)) || !all(B)) stop(...) }

Best,
H.

-- 
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 fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] stopifnot() does not stop at first non-TRUE argument
=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=