Re: [R] A stopifnot() nastiness, even if not a bug

2020-05-09 Thread Martin Maechler
> Martin Maechler > on Mon, 13 Apr 2020 22:30:35 +0200 writes: > William Dunlap > on Mon, 13 Apr 2020 09:57:11 -0700 writes: >> You can avoid the problem in Martin's example by only giving scalars to >> stopifnot(). E.g., using stopifnot(all(x>0)) or

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread Martin Maechler
> William Dunlap > on Mon, 13 Apr 2020 09:57:11 -0700 writes: > You can avoid the problem in Martin's example by only giving scalars to > stopifnot(). E.g., using stopifnot(all(x>0)) or stopifnot(length(x)==1, x> 0) instead of stopifnot(x>0). I think having stopifnot

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread William Dunlap via R-help
You can avoid the problem in Martin's example by only giving scalars to stopifnot(). E.g., using stopifnot(all(x>0)) or stopifnot(length(x)==1, x>0) instead of stopifnot(x>0). I think having stopifnot call all(predicate) if length(predicate)!=1 was probably a mistake. Bill Dunlap TIBCO Software

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread Hervé Pagès
On 4/13/20 05:30, Martin Maechler wrote: peter dalgaard on Mon, 13 Apr 2020 12:00:38 +0200 writes: > Inline... >> On 13 Apr 2020, at 11:15 , Martin Maechler wrote: >> >>> Bert Gunter >>> on Sun, 12 Apr 2020 16:30:09 -0700 writes: >> >>>

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread Martin Maechler
> peter dalgaard > on Mon, 13 Apr 2020 12:00:38 +0200 writes: > Inline... >> On 13 Apr 2020, at 11:15 , Martin Maechler wrote: >> >>> Bert Gunter >>> on Sun, 12 Apr 2020 16:30:09 -0700 writes: >> >>> Don't know if this has come up before, but

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread peter dalgaard
Inline... > On 13 Apr 2020, at 11:15 , Martin Maechler wrote: > >> Bert Gunter >>on Sun, 12 Apr 2020 16:30:09 -0700 writes: > >> Don't know if this has come up before, but ... >>> x <- c(0,0) >>> length(x) >> [1] 2 >> ## but >>> stopifnot(length(x)) >> Error: length(x) is not TRUE

Re: [R] A stopifnot() nastiness, even if not a bug

2020-04-13 Thread Martin Maechler
> Bert Gunter > on Sun, 12 Apr 2020 16:30:09 -0700 writes: > Don't know if this has come up before, but ... >> x <- c(0,0) >> length(x) > [1] 2 > ## but >> stopifnot(length(x)) > Error: length(x) is not TRUE > Called from: top level > ## but >>

[R] A stopifnot() nastiness, even if not a bug

2020-04-12 Thread Bert Gunter
Don't know if this has come up before, but ... > x <- c(0,0) > length(x) [1] 2 ## but > stopifnot(length(x)) Error: length(x) is not TRUE Called from: top level ## but > stopifnot(length(x) > 0) ## not an error; nor is > stopifnot(as.logical(length(x))) ## Ouch! Maybe the man page should say