I would like to replace all NA values in numeric columns in my data frame with 0. How should I go about it?
I come as far as getting a list of numeric variables with NA values as follows (I am sure it is not optimal):
iris[3,4] <- NA
missingVars <- iris[colSums(is.na(iris)) > 0]
missingNumVars <- missingVars[sapply(missingVars, is.numeric)]
Something like this will work and avoid the duplicate copies of an object of the same size
iris(created byis.na(iris))