Is there a single function in R that determines if a value is NA
, NaN
, Inf
, -Inf
, or otherwise not a well-formed number?
The function dataframe. isnull(). sum(). sum() returns the number of missing values in the data set.
You can also test for missing values using the MATCH function. MATCH finds the position of an item in a list and will return the #N/A error when a value is not found. You can use this behavior to build a formula that returns "Missing" or "OK" by testing the result of MATCH with the ISNA function.
nan() Function for Finding Missing values: A logical vector is returned by this function that indicates all the NaN values present. It returns a Boolean value.
You want is.finite
> is.finite(NA)
[1] FALSE
> is.finite(NaN)
[1] FALSE
> is.finite(Inf)
[1] FALSE
> is.finite(1L)
[1] TRUE
> is.finite(1.0)
[1] TRUE
> is.finite("A")
[1] FALSE
> is.finite(pi)
[1] TRUE
> is.finite(1+0i)
[1] TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With