The reason is probably that any(logical()) and any(!logical()) return FALSE (there are no TRUEs in logical(0)). Bill Dunlap TIBCO Software wdunlap tibco.com
On Fri, Dec 11, 2015 at 5:38 AM, Dario Beraldi <dario.bera...@gmail.com> wrote: > Hi All, > > I'd like to understand the reason why stopifnot(logical(0) == x) doesn't > (never?) throw an exception, at least in these cases: > > stopifnot(logical(0) == 1) > stopifnot(logical(0) == TRUE) > stopifnot(logical(0) == FALSE) > > My understanding is that logical(0) is an empty set, so I would expect the > above tests to fail. > > (I got bitten by this in a piece of code where "x" happened to be > logical(0) and stopifnot didn't catch it) > > Thanks! > Dario > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.