Re: [R] stopifnot with logical(0)

2015-12-14 Thread Martin Maechler
> "DM" == Duncan Murdoch > on Sat, 12 Dec 2015 09:05:04 -0500 writes: DM> On 12/12/2015 8:44 AM, peter dalgaard wrote: >> >>> On 12 Dec 2015, at 10:54 , Martin Maechler >>> wrote: >>> >>> My conclusion:

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Hadley Wickham
On Sat, Dec 12, 2015 at 1:51 PM, Martin Maechler wrote: >> Hadley Wickham >> on Sat, 12 Dec 2015 08:08:54 -0600 writes: > > > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > > wrote: >

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Duncan Murdoch
On 14/12/2015 11:10 AM, Hadley Wickham wrote: On Sat, Dec 12, 2015 at 1:51 PM, Martin Maechler wrote: >> Hadley Wickham >> on Sat, 12 Dec 2015 08:08:54 -0600 writes: > > > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > >

Re: [R] stopifnot with logical(0)

2015-12-14 Thread William Dunlap
Hadley wrote > * all.equal is suboptimal because it returns TRUE or a text string That feature works ok with stopifnot(): > stopifnot(all.equal("one", 1)) Error: all.equal("one", 1) are not all TRUE and I suppose stopifnot could be enhanced to print the text strings that all.equal() returns

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Duncan Murdoch
On 14/12/2015 11:45 AM, Hadley Wickham wrote: >> I wonder if R is missing an equality operator for this case. Currently: >> >> * == is suboptimal because it's vectorised >> * all.equal is suboptimal because it returns TRUE or a text string >> * identical is suboptimal because it doesn't do

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Hadley Wickham
>> I wonder if R is missing an equality operator for this case. Currently: >> >> * == is suboptimal because it's vectorised >> * all.equal is suboptimal because it returns TRUE or a text string >> * identical is suboptimal because it doesn't do common coercions >> >> Do we need another function

Re: [R] stopifnot with logical(0)

2015-12-13 Thread William Dunlap
> as Bill or Jeff explained, "the empty set is always true" My wording was that any(logical(0)) is FALSE because "there are no TRUEs in logical(0)". Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, Dec 12, 2015 at 1:54 AM, Martin Maechler wrote: >> Henrik

Re: [R] stopifnot with logical(0)

2015-12-13 Thread peter dalgaard
> On 13 Dec 2015, at 20:31 , William Dunlap wrote: > >> as Bill or Jeff explained, "the empty set is always true" > > My wording was that any(logical(0)) is FALSE because "there are no > TRUEs in logical(0)". Yes. My mind still boggles over how the empty set slipped into

Re: [R] stopifnot with logical(0)

2015-12-12 Thread peter dalgaard
> On 12 Dec 2015, at 10:54 , Martin Maechler wrote: > > My conclusion: Breaking such a fundamental lemma of logic as > "the empty set is always true" Umm, that doesn't make sense to me. Surely you mean that "an AND-operation over an empty index set is TRUE"? A

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Martin Maechler
> Henrik Bengtsson > on Fri, 11 Dec 2015 08:20:55 -0800 writes: > On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius wrote: >> >>> On Dec 11, 2015, at 5:38 AM, Dario Beraldi wrote: >>>

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Hadley Wickham
On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler wrote: >> Henrik Bengtsson >> on Fri, 11 Dec 2015 08:20:55 -0800 writes: > > > On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius > wrote: > >> >

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Duncan Murdoch
On 12/12/2015 8:44 AM, peter dalgaard wrote: On 12 Dec 2015, at 10:54 , Martin Maechler wrote: My conclusion: Breaking such a fundamental lemma of logic as "the empty set is always true" Umm, that doesn't make sense to me. Surely you mean that "an

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Henrik Bengtsson
On Sat, Dec 12, 2015 at 6:08 AM, Hadley Wickham wrote: > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > wrote: >>> Henrik Bengtsson >>> on Fri, 11 Dec 2015 08:20:55 -0800 writes: >> >> > On Fri, Dec

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Duncan Murdoch
On 12/12/2015 9:08 AM, Hadley Wickham wrote: On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler wrote: Henrik Bengtsson on Fri, 11 Dec 2015 08:20:55 -0800 writes: > On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Martin Maechler
> Hadley Wickham > on Sat, 12 Dec 2015 08:08:54 -0600 writes: > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > wrote: >>> Henrik Bengtsson on >>> Fri, 11 Dec 2015 08:20:55 -0800

[R] stopifnot with logical(0)

2015-12-11 Thread Dario Beraldi
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

Re: [R] stopifnot with logical(0)

2015-12-11 Thread Henrik Bengtsson
On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius wrote: > >> On Dec 11, 2015, at 5:38 AM, Dario Beraldi wrote: >> >> Hi All, >> >> I'd like to understand the reason why stopifnot(logical(0) == x) doesn't >> (never?) throw an exception, at least in

Re: [R] stopifnot with logical(0)

2015-12-11 Thread Jeff Newmiller
The goal of the comparison operators is to obtain a logical value. Why compare logical values... you clearly already have that? stopifnot( logicalvariable ) and stopifnot( !logicalvariable ) are sensible, but not stopifnot( logicalvariable == TRUE ) or stopifnot( logicalvariable == FALSE )

Re: [R] stopifnot with logical(0)

2015-12-11 Thread Giorgio Garziano
I think the inspection of the "stopifnot()" source code may help. > stopifnot function (...) { n <- length(ll <- list(...)) if (n == 0L) return(invisible()) mc <- match.call() for (i in 1L:n) if (!(is.logical(r <- ll[[i]]) && !anyNA(r) && all(r))) { ch <-

Re: [R] stopifnot with logical(0)

2015-12-11 Thread David Winsemius
> On Dec 11, 2015, at 5:38 AM, Dario Beraldi 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: The usual way to test for a length-0 logical object is to use length():

Re: [R] stopifnot with logical(0)

2015-12-11 Thread William Dunlap
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 wrote: > Hi All, > > I'd like to understand the reason why