[R] identical() vs all( . == .) [was "strange things..."]

Martin Maechler maechler at stat.math.ethz.ch
Wed Sep 4 09:49:24 CEST 2002


>>>>> "MM" == Martin Maechler <maechler at stat.math.ethz.ch>
>>>>>     on Wed, 4 Sep 2002 09:37:39 +0200 writes:

	     ...

    MM> identical() has still been underused quite a bit,
    MM> probably even in base R code.  In many cases,
    MM> identical(x,y) is now preferable to
    MM> all(x == y)

    MM> even when the latter does work.

I think I should add some caution:

Do not think of replacing  all(x == y) by identical(x,y) everywhere!

E.g.  1:3 == as.double(1:3) is all TRUE, but are not identical(.,.),
or also
   all(c(a="A", b="B") == c("A","B"))
is TRUE where identical() isn't and shouldn't be.

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list