title: How to speed up missing search process in a R data.table
body: <p>I am writing a general function for missing value treatment. Data can have Char,numeric,factor and integer type columns. An example of data is as follows</p>
  
  <pre><code>dt&lt;-data.table(
    num1=c(1,2,3,4,NA,5,NA,6),
    num3=c(1,2,3,4,5,6,7,8),
    int1=as.integer(c(NA,NA,102,105,NA,300,400,700)),
    int3=as.integer(c(1,10,102,105,200,300,400,700)),
    cha1=c('a','b','c',NA,NA,'c','d','e'),
    cha3=c('xcda','b','c','miss','no','c','dfg','e'),
    fact1=c('a','b','c',NA,NA,'c','d','e'),
    fact3=c('ad','bd','cc','zz','yy','cc','dd','ed'),
    allm=as.integer(c(NA,NA,NA,NA,NA,NA,NA,NA)),
    miss=as.character(c("","",'c','miss','no','c','dfg','e')),
    miss2=as.integer(c('','',3,4,5,6,7,8)),
    miss3=as.factor(c(".",".",".","c","d","e","f","g")),
    miss4=as.factor(c(NA,NA,'.','.','','','t1','t2')),
    miss5=as.character(c(NA,NA,'.','.','','','t1','t2'))  
  )
  </code></pre>
  
  <p>I was using this code to flag out missing values:</p>
  
  <pre><code>dt[,flag:=ifelse(is.na(miss5)|!nzchar(miss5),1,0)]
  </code></pre>
  
  <p>But it turns out to be very slow, additionally I have to add logic which could also consider "." as missing.
   So I am planning to write this for missing value identification</p>
  
  <pre><code>dt[miss5 %in% c(NA,'','.'),flag:=1]
  </code></pre>
  
  <p>but on a 6 million record set it takes close to 1 second to run this whereas</p>
  
  <pre><code>dt[!nzchar(miss5),flag:=1]  takes close 0.14 secod to run.
  </code></pre>
  
  <p>My question is, can we have a code where the time taken is as least as possible while we can look for values NA,blank and Dot(NA,".","") as missing?</p>
  
  <p>Any help is highly appreciated.</p>