In R,
a.
Missing
values are represented by the symbol NA (stands for Not Available).
b.
Impossible
values are represented by NaN (stands for Not a Number).
Ex: Divide by zero.
How to check for missing values, impossible values
R provides
is.na(), is.nan() functions to check for missing, impossible values.
is.na()
function return true, if there is missing value, else false.
is.nan()
function return true, if there is impossible value, else false.
> vector1 <- c(1, 2, 3, NaN) > is.na(vector1) [1] FALSE FALSE FALSE TRUE > is.nan(vector1) [1] FALSE FALSE FALSE TRUE > > > vector1 <- c(1, 2, 3, NA) > is.na(vector1) [1] FALSE FALSE FALSE TRUE > is.nan(vector1) [1] FALSE FALSE FALSE FALSE
A NaN value
is also NA, but converse is not true. Above example proves this.
No comments:
Post a Comment