NaN values throwing different results using naniar

Can someone explain the below results. It's really weird how NaN is detected:
image

The NaN and Inf in the second vector are implicitly coerced into characters because of other character elements in the vector ("." and "missing"), whereas the NA is maintained. "Not a Number" (NaN) and "infinity" (Inf) do not makes sense to keep in a character vector as "special values" because they have no meaning in a character vector (as they would in numeric vectors). In contrast, the NA (i.e., missing value) still makes sense to keep in a character vector.

x = c(NA, NaN)
x
[1] NA NaN
class(x)
[1] "numeric"
are_na(x)
[1] TRUE TRUE
x = c(NA, NaN, Inf, ".", "missing")
x
[1] NA "NaN" "Inf" "." "missing"
class(x)
[1] "character"
are_na(x)
[1] TRUE FALSE FALSE FALSE FALSE

Hope that makes sense,
Snehal

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Thanks, yeah that definitely does make sense.