Currently, NaN is treated as if a non-NA value but I expect it's the same as NA_real_, because is.na(NaN) returns TRUE.
library(data.table)
coalesce(NaN, 1)
#> [1] NaN
is.na(NaN)
#> [1] TRUE
Created on 2019-08-26 by the reprex package (v0.2.1)
should be a matter of changing ISNA to ISNAN in https://github.com/Rdatatable/data.table/blob/d95910733167684b05ce253dcb4da801bde54f56/src/coalesce.c#L99-L118
the question is if we agree on such behaviour
I think that because is.na(NaN) default should be to consider it as NA. Both dplyr and hutils do so.
In the future, if requested, we could add an option, but I think we should do this for now.
(PS we're already doing this for complex input: coalesce(NaN + NaN*1i, 1 + 1i) -> 1+1i)
Most helpful comment
should be a matter of changing
ISNAtoISNANin https://github.com/Rdatatable/data.table/blob/d95910733167684b05ce253dcb4da801bde54f56/src/coalesce.c#L99-L118the question is if we agree on such behaviour