I am trying to create a function which can find missing location and impute the missing in a data table. Now this function uses is.na()
extensively to find out the missing location and also to replace it with imputation value. It is working fine for all type of variable until input is character
type column and have blank cells as missing, because is.na()
is not able to identify it as missing hence it skips these cells for imputation.
Example:
library(data.table)
t<-data.table(x=c('an','ax','','az'),y=c('bn','','bz','bx'))
x y
1: an bn
2: ax
3: bz
4: az bx
is.na(t[,x])
[1] FALSE FALSE FALSE FALSE
where it should be
[1] FALSE FALSE TRUE FALSE
Any help is highly appreciated.
Thanks.