>>>>> 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
    >> stopifnot(length(x) > 0)  ## not an error;  nor is
    >> stopifnot(as.logical(length(x)))
    > ## 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 ?

> Description:

>      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.

Martin

______________________________________________
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.

Reply via email to