Skip to content
Prev 6070 / 63468 Next

Wierd problem comparing numeric values and list using == (PR#1076)

Peter Dalgaard BSA wrote:
....
identical essentially applies itself recursively until it encounters an
non-recursive element (in which case it does element-wise comparisons or
something specific to the special type, such as a symbol).  

My take is that the "==" operator is for generating data structures that
look like the arguments but with TRUE, FALSE, or NA in the appropriate
elements. Notice, e.g., that identical(1,NA) is FALSE while 1==NA is NA.

It's possible one would like to do == recursively to all the elements of
two lists, suggesting an lapply of the "==" function.  (R doesn't yet
have a recursive apply to do this at all levels of recursion.)

But in most examples I've seen, users really wanted a single TRUE/FALSE
result, in which case they should _not_ be using the "==" operator.

John