Identifying and removing “NA”s and other errors [duplicate]
-
30-01-2021 - |
Question
Possible Duplicate:
Test for NA and select values based on result
Suppose you have a vector -- you do a calculation on the vector -- many of the elements return "NA" -- how do you identify these "NA"s and change them to some usable integer
Solution
Assuming that your data is in dat
(could be a vector, matrix, or data frame):
dat[is.na(dat)]<-0
replaces all NA
entries of dat
with 0
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow