[R] Question about is.na for missing data

David Kaplan dkaplan at education.wisc.edu
Thu Oct 29 17:45:19 CET 2009


I am trying to a simple mean imputation using the following command 
(yes, I know it is not an ideal way to impute missing data)

asd[is.na(asd)] <- mean(asd,na.rm=TRUE)

This has worked quite well in the past.  Now, however, I am getting the 
following error messsage.

Error in `[<-.data.frame`(`*tmp*`, is.na(asd), value = 
c(2433.64150943396,  :
  rhs is the wrong length for indexing by a logical matrix

An inspection of the data set reveals no value of the sort give above.  
Any thoughts?

Thanks in advance,


More information about the R-help mailing list