Skip to content
Prev 40353 / 63424 Next

NaN, Inf to NA

On 27/05/2011 11:11 AM, Martin Maechler wrote:
I think you may have misunderstood my proposal.  Currently is.nan, 
is.finite and is.infinite have no data.frame methods, so the default 
method is used.  The problem is that the default method is too 
permissive:  it operates on the data.frame by treating it as a list; 
then it returns FALSE for each list element.  (If there is only one row, 
it applies the test to the singleton in the column.)   This is pretty 
strange default behaviour.

What I'm proposing is that the default method should trigger an error if 
you try to send it anything that's not atomic.  This gives sensible 
behaviour in most cases; the only one where it doesn't work is a list of 
singletons, which used to be handled sensibly, but will now fail.

(There's still a question about what the answer should be for these 
functions when applied to character or raw vectors, which are both 
atomic.  I'm leaning towards returning FALSE for every element, which 
matches the current behaviour, but perhaps those should also generate an 
error.)

I think this partially addresses Bill's objection, but not completely.  
Someone could still put a class on an atomic vector, and that might not 
be handled properly by the default method.
Where I've moved it now.

Duncan Murdoch