title: transform all columns that are NAs from numeric to factors
body: <p>I have a <code>data.table</code> called <code>td.br.2</code>, in which some columns are <strong>completely</strong> <code>NAs</code>. These columns are of type <code>numeric</code>. What I would like to do, is <strong>only</strong> for these columns to transform them to factors. </p>
  
  <p>I have tried the following, but it does not work ( I do not get an error but it does not do the job either)</p>
  
  <pre><code>td.br.2[] &lt;- td.br.2[,lapply(.SD, function(x) {ifelse(sum(is.na(x)==nrow(td.br.2)),as.factor(x),x)})]
  </code></pre>