Skip to content
Prev 2140 / 63424 Next

matrix() can't handle NaN (PR#193)

On Tue, 11 May 1999, Bill Simpson wrote:
[examples with read.table(...,na.strings="NaN") snipped]
I'm going to defer this to people who know more than I about 
consistency and the differences between NA and NaN.  I will note that
the help for is.na() says:

The generic function `is.na' returns a logical vector of the same ``form''
as its argument `x', containing `TRUE' for those elements marked `NA' or
`NaN' (!) and `FALSE' otherwise.

  The (!) suggests that whoever wrote the help file recognized some 
subtlety here ... [similarly, is.finite() recognizes NA as a non-finite 
number]

  This seems to fall in the general category of "how do we help people 
avoid 'gotchas' in R that, while logical, are not necessarily what they 
expect?  Can we do this without blurring logical distinctions that are 
interesting/important/significant to more knowledgeable users?"

  One *could* extend the default na.strings in read.table to 
c("NA","NaN"), which would take care of the immediate problem but might 
further blur the subtle distinction between NA and NaN.  I don't know 
how/whether one would want to extend read.table() to deal with Inf/-Inf 
in data files ... (I think not).

  Ben
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._