[Rd] NA and NaN in function identical

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 29 17:53:05 CEST 2007


On Wed, 29 Aug 2007, Petr Savicky wrote:

> 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.

And sometimes they are:

> identical(y,x)
[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.

>
> Tested under R version 2.5.1 Patched (2007-08-19 r42638) on Linux (CPU Xeon).
>
> Petr Savicky.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list