Re: [Rd] NA and NaN in function identical

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 29 Aug 2007 16:53:05 +0100 (BST)

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 29 Aug 2007 - 22:16:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 29 Aug 2007 - 22:40:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.