[R] A stopifnot() nastiness, even if not a bug
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Mon Apr 13 11:15:54 CEST 2020
>>>>> 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)
>  2
> ## but
> Error: length(x) is not TRUE
> Called from: top level
> ## but
>> stopifnot(length(x) > 0) ## not an error; nor is
> ## Ouch!
> Maybe the man page should say something about not assuming automatic
> coercion to logical, which is the usual expectation. Or fix this.
> Bert Gunter
Well, what about the top most paragraph of the help page is not clear here ?
> If any of the expressions (in '...' or 'exprs') are not 'all'
> 'TRUE', 'stop' is called, producing an error message indicating
> the _first_ expression which was not ('all') true.
If useR's expectations alone would guide the behavior of a
computer language, the language would have to behave
"personalized" and give different results depending on the user,
which may be desirable in medicine or psychotherapy but not with R.
More information about the R-help