I was looking for a way to replace NA's in my dataframe with zero's, and found a great reply here: How do I replace NA values with zeros in an R dataframe?
I used the code in aL3xa's answer to build an example matrix and found the NA's were replaced fine. However, when I came to apply the code to my own dataframe, it does not seem to work:
sum(is.na(dat.sub))
[1] 453562
dat.sub[is.na(dat.sub)] <- 0
sum(is.na(dat.sub))
[1] 453562
Can anyone suggest what I might be doing wrong?