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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to