help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between NaN and NA?


From: Jaroslav Hajek
Subject: Re: Difference between NaN and NA?
Date: Thu, 8 Apr 2010 20:48:08 +0200

On Thu, Apr 8, 2010 at 6:05 PM, CdeMills <address@hidden> wrote:
>
>
> John W. Eaton wrote:
>>
>>
>> Right, I added this feature to Octave specifically for compatibility
>> with NA in R.  The idea was to be able to exchange binary data with R
>> and preserve the special NaN value that R uses for NA.
>>
>> | In the current situation, NA's do no harm in Octave, but they're also
>> | not much useful, because most functions ignore them, for instance,
>> | mean ([1,2,3,NA]) is NA etc.
>> | On the contrary, inserting checks for NA's everywhere is a good idea
>> | either, because it will slow things down for everyone.
>>
>> Yes, I assume R has a lot of special checks for NA (and that you meant
>> "is not a good idea".  Un?fortunately, no one was ever motivated to
>> make Octave functions NA-aware.  So the value exists, but it is not
>> really used for anything.
>>
>> Also, there is no guarantee that NA will be preserved across a
>> function call.  For example, on some platforms, you might see
>> something like
>>
>
> 'NA' is an heritage of SQL. It is mostly used in statistical context, to
> compute f.i. degrees of freedom, the number of available data. By default,
> in R, everything touching NA becomes NA,

Actually, this is not quite true. R 2.7.1 shows the same what Octave does:

> NaN + NA
[1] NaN
> NA + NaN
[1] NA

of course, if any operand is NA, the result should be NA.

> except if the flag na.rm is set to
> true. So, about performances, this adds a logical test at the functions
> start, is this a performance issue ?
>

It's not a performance issue in R because you explicitly say that you
want the test. But it is inconvenient.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]