Why is NA == NA = NA?
Most Objects in R compared to themselves return TRUE but no NA. It’s actually i had never thought about but thinking about it makes some alot of sense, Comparing two Unknowns shouldn’t be return TRUE.
Let’s Look at some of the Most Common examples that return TRUE
10 == 10
## [1] TRUE
-10 == -10
## [1] TRUE
FALSE == FALSE
## [1] TRUE
"NA" == "NA"
## [1] TRUE
This is a string “NA” and not the NA we are talking about and will return a TRUE just like any other similar string comparison
So Why
Think about it this way, if i say i have NA Dollars in my bank account and you also have NA Dollars in your bank account. I can’t confidently say we have an equal amount in our bank accounts because we i don’t know how much you got and so do you.
So a comparison of Our Bank account balances is surely Unknown. Hence NA
NA == NA
## [1] NA