[Rd] isFALSE

Martin Maechler maechler at stat.math.ethz.ch
Tue Oct 20 16:55:40 CEST 2009


>>>>> "RF" == Romain Francois <romain.francois at dbmail.com>
>>>>>     on Sun, 11 Oct 2009 01:00:24 +0200 writes:

    RF> Hello, Just wondering why there is "isTRUE" and not
    RF> "isFALSE".

Probably because it's slightly more natural to have

  if(isTRUE(....)) {
     ..
  }

rather than the corrsponding  isFALSE()

Further, e.g.  all.equal()  and  validObject()
return *either*  TRUE or a string,
and hence isTRUE(.) is usefully applied to their return values.

Are there other opinions on this?

Martin

    > -- 
    > Romain Francois
    > Professional R Enthusiast
    > +33(0) 6 28 91 30 30
    > http://romainfrancois.blog.free.fr
    > |- http://tr.im/BcPw : celebrating R commit #50000
    > |- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
    > `- http://tr.im/yw8E : New R package : sos

    > Index: src/library/base/R/identical.R
    > ===================================================================
    > --- src/library/base/R/identical.R	(revision 50027)
    > +++ src/library/base/R/identical.R	(working copy)
    > @@ -18,3 +18,5 @@
    > .Internal(identical(x,y, num.eq, single.NA, attrib.as.set))
 
    > isTRUE <- function(x) identical(TRUE, x)
    > +
    > +isFALSE <- function(x) identical(FALSE, x)
    > Index: src/library/base/man/Logic.Rd
    > ===================================================================
    > --- src/library/base/man/Logic.Rd	(revision 50027)
    > +++ src/library/base/man/Logic.Rd	(working copy)
    > @@ -14,6 +14,7 @@
    > xor(x, y)
 
    > isTRUE(x)
    > +isFALSE(x)
    > }
    > \alias{!}
    > \alias{&}
    > @@ -23,6 +24,7 @@
    > \alias{xor}
    > \alias{Logic}
    > \alias{isTRUE}
    > +\alias{isFALSE}
    > \description{
    > These operators act on logical and number-like vectors.
    > }
    > @@ -48,7 +50,11 @@
    > \code{isTRUE(x)} is an abbreviation of \code{identical(TRUE, x)}, and
    > so is true if and only if \code{x} is a length-one logical vector with
    > no attributes (not even names).
    > -
    > +  
    > +  \code{isFALSE(x)} is an abbreviation of \code{identical(FALSE, x)}, and
    > +  so is true if and only if \code{x} is a length-one logical vector with
    > +  no attributes (not even names).
    > +  
    > Numeric and complex vectors will be coerced to logical values, with
    > zero being false and all non-zero values being true.  Raw vectors are
    > handled without any coercion for \code{!}, \code{&}, \code{|} and
    > @@ -87,7 +93,7 @@
    > used.  For arrays (and an array result) the dimensions and dimnames
    > are taken from first argument if it is an array, otherwise the second.
 
    > -  For \code{||}, \code{&&} and \code{isTRUE}, a length-one logical vector.
    > +  For \code{||}, \code{&&}, \code{isFALSE} and \code{isTRUE}, a length-one logical vector.
    > }
    > \section{S4 methods}{
    > \code{!}, \code{&} and \code{|} are S4 generics, the latter two part
    > Index: src/library/base/man/identical.Rd
    > ===================================================================
    > --- src/library/base/man/identical.Rd	(revision 50027)
    > +++ src/library/base/man/identical.Rd	(working copy)
    > @@ -85,7 +85,8 @@
    > \seealso{
    > \code{\link{all.equal}} for descriptions of how two objects differ;
    > \link{Comparison} for operators that generate elementwise comparisons.
    > -  \code{\link{isTRUE}} is a simple wrapper based on \code{identical}.
    > +  \code{\link{isTRUE}} and \code{\link{isFALSE}} are simple 
    > +  wrappers based on \code{identical}.
    > }
    > \examples{
    > identical(1, NULL) ## FALSE -- don't try this with ==
    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list