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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that your data is in
dat(could be a vector, matrix, or data frame):dat[is.na(dat)]<-0replaces all
NAentries ofdatwith0.