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

2020-01-02 Thread Tomas Kalibera

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,  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=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=zFj3lh-N_YlNBRlDKeO-aTs0Bf2qtWLUHKlw_nh2Q4o=

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@r-project.org mailing list


https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=tCCxZtQj30QrtAYORMODT-OnjeKiXxiF0qlZtgyj1Mc=
--
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: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2020-01-01 Thread Jan Gorecki
"nana" is meant to express "NA, really NA".
Your suggestion sounds good.

On Thu 2 Jan, 2020, 3:38 AM Pages, Herve,  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=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=zFj3lh-N_YlNBRlDKeO-aTs0Bf2qtWLUHKlw_nh2Q4o=
> > 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@r-project.org mailing list
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=tCCxZtQj30QrtAYORMODT-OnjeKiXxiF0qlZtgyj1Mc=
> >
>
> --
> 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: hpa...@fredhutch.org
> Phone:  (206) 667-5791
> Fax:(206) 667-1319
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2020-01-01 Thread Pages, Herve
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=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=zFj3lh-N_YlNBRlDKeO-aTs0Bf2qtWLUHKlw_nh2Q4o=
> 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@r-project.org mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=oWT1wDiy7pogVlJHGtdOoM3zdB45t9zZVyGYU8qcOgo=tCCxZtQj30QrtAYORMODT-OnjeKiXxiF0qlZtgyj1Mc=
> 

-- 
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: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel