[Rd] New R function is.nana = is.na & !is.nan

Tomas Kalibera tom@@@k@||ber@ @end|ng |rom gm@||@com
Thu Jan 2 21:11:56 CET 2020


Please note that ?NaN says

"Computations involving ‘NaN’ will return ‘NaN’ or perhaps ‘NA’: which 
of those two is not guaranteed and may depend on the R platform (since 
compilers may re-order computations)."

It is not reliable to depend on the distinction between NA and (non-NA) 
NaN. Part of the problem is that on some current systems it is not 
specified what the NaN payload will be after even simple arithmetic 
operations. Unfortunately changing R to make such distinction reliable  
would be a major effort, most likely incur performance overhead even for 
computations where the distinction is not needed, and code changes would 
be required also in packages.

I think given this it is better not to offer a function to directly 
differentiate between NaN and NA.

Best
Tomas

On 1/2/20 3:09 AM, Jan Gorecki wrote:
> "nana" is meant to express "NA, really NA".
> Your suggestion sounds good.
>
> On Thu 2 Jan, 2020, 3:38 AM Pages, Herve, <hpages using fredhutch.org> wrote:
>
>> Happy New Year everybody!
>>
>> The name (is.nana) doesn't make much sense to me. Can you explain it?
>>
>> One alternative would be to add an extra argument (e.g. 'strict') to
>> is.na(). FALSE by default, and ignored (with or w/o a warning) when the
>> type of 'x' is not "numeric".
>>
>> H.
>>
>>
>> On 12/31/19 22:16, Jan Gorecki wrote:
>>> Hello R-devel,
>>>
>>> Best wishes in the new year. I am writing to kindly request new R
>>> function so NA_real_ can be more easily detected.
>>> Currently if one wants to test for NA_real_ (but not NaN) then extra
>>> work has to be done: `is.na(x) & !is.nan(x)`
>>> Required functionality is already at C level so to address my request
>>> there is not that much to do.
>>> Kevin Ushey made a nice summary of current R C api in:
>>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_a_26262984_2490497&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo&s=zFj3lh-N_YlNBRlDKeO-aTs0Bf2qtWLUHKlw_nh2Q4o&e=
>>> Pasting related part below, extra row added by me is a requested feature.
>>>
>>>       +---------------------+
>>>       | C fun    | NaN | NA | R fun
>>>       +---------------------+
>>>       | ISNAN    |  t  | t  | is.na
>>>       | R_IsNaN  |  t  | f  | is.nan
>>>       | ISNA     |  f  | t  | is.na && !is.nan
>>>       | R_IsNA   |  f  | t  | is.na && !is.nan
>>>       +---------------------+
>>>       +---------------------+
>>>       | R fun    | NaN | NA | C fun
>>>       +---------------------+
>>>       | is.na    |  t  | t  | ISNAN
>>>       | is.nan   |  t  | f  | R_IsNaN
>>>       +---------------------+
>>>       | is.nana  |  f  | t  | R_IsNA
>>>       +---------------------+
>>>
>>> Strictly speaking, I am asking for a new R function:
>>>
>>>       is.nana <- function(x) if (typeof(x)=="numeric")
>>> .Primitive("is.nana") else .Primitive("is.na")
>>>
>>> Then probably a copy of C function `do_isnan` as `do_isnana` with a
>>> minor change from `R_IsNaN` to `R_IsNA`.
>>>
>>> Best,
>>> Jan Gorecki
>>>
>>> ______________________________________________
>>> R-devel using r-project.org mailing list
>>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo&s=tCCxZtQj30QrtAYORMODT-OnjeKiXxiF0qlZtgyj1Mc&e=
>> --
>> Hervé Pagès
>>
>> Program in Computational Biology
>> Division of Public Health Sciences
>> Fred Hutchinson Cancer Research Center
>> 1100 Fairview Ave. N, M1-B514
>> P.O. Box 19024
>> Seattle, WA 98109-1024
>>
>> E-mail: hpages using fredhutch.org
>> Phone:  (206) 667-5791
>> Fax:    (206) 667-1319
>>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list