r - How to correctly convert NaN to NA -


on given double vector, how come can define -999 na by

v[v == -999] <- na 

but not

v[v == nan] <- na 

and how convert nan's na's correctly?

== doesn't work testing na , nan values. because, data perspective, 2 missing values may or may not same. use is.na() , is.nan() test those.

what want v[is.nan(v)] <- na

you can find details in pages @ ?nan , ?na.

this mentioned on pages, it's worth pointing out nan treated special type of na, behavior:

> is.na(nan) [1] true  > is.nan(na) [1] false 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -