Skip to content

NA and NaN in function identical

2 messages · Petr Savicky, Brian Ripley

#
The help page for function identical says:
     'identical' sees 'NaN' as different from 'as.double(NA)', but all
     'NaN's are equal (and all 'NA' of the same type are equal).
However, we have
  x <- NaN
  y <- as.double(NA)
  x # [1] NaN
  y # [1] NA
  identical(x,y) # [1] TRUE

In my opinion, NaN and as.double(NA) should be distinguished as the 
help page suggests.

Tested under R version 2.5.1 Patched (2007-08-19 r42638) on Linux (CPU Xeon).

Petr Savicky.
#
On Wed, 29 Aug 2007, Petr Savicky wrote:

            
And sometimes they are:
[1] FALSE

so it is a bug.  A quicker version:

identical(NaN, NA_real_) == identical(NA_real_, NaN)

was false, fixed now, thanks for spotting it.