From maechler at stat.math.ethz.ch  Mon Oct 23 18:36:05 2017
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 23 Oct 2017 18:36:05 +0200
Subject: [Rd] range function with finite=T and logical parameters
In-Reply-To: <A7D1EB89-0A3C-456D-A73C-6E3B2B11DF3E@oracle.com>
References: <A7D1EB89-0A3C-456D-A73C-6E3B2B11DF3E@oracle.com>
Message-ID: <23022.6773.353931.80946@stat.math.ethz.ch>

>>>>> Lukas Stadler <lukas.stadler at oracle.com>
>>>>>     on Mon, 23 Oct 2017 15:56:55 +0200 writes:

    > Hi!
    > I was wondering about the behavior of the range function wrt. logical NAs:

    >> range(c(0L, 1L, NA), finite=T)
    > [1] 0 1
    >> range(c(F, T, NA), finite=T)
    > [1] NA NA

    > The documentation is quite clear that "finite = TRUE includes na.rm = TRUE?, so that I would have assumed that these two snippets would produce the same result.

    > - Lukas


I agree.  Further, another informal "rule" would require that the two calls

     range(L, *)  
     range(as.numeric(L), *)

are equivalent for logical vectors L without attributes.
I'll look into fixing this by an obvious change to (R-level)
range.default().

------

Note for the more advanced ones -- i.e. typical R-devel readers :

T and F are variables in R.  For that reason, using the language
keywords TRUE and FALSE is much preferred in such cases.  For
some tests we'd even use

    T <- FALSE

or even

    delayedAssign("F", stop("do not use 'F'  when programming with R"))

before running the tests -- just do ensure that the code to be
tested does not use these short forms.


Thank you, Lukas,  for the report!

Best,
Martin



[Rd] range function with finite=T and logical parameters
Martin Maechler