title: Replace NA with 0, only in numeric columns in data.table
body: <p>I have a data.table with columns of different data types. My goal is to select only numeric columns and replace NA values within these columns by 0.
  I am aware that replacing na-values with zero goes like this:</p>
  
  <pre><code>DT[is.na(DT)] &lt;- 0
  </code></pre>
  
  <p>To select only numeric columns, I found this solution, which works fine:</p>
  
  <pre><code>DT[, as.numeric(which(sapply(DT,is.numeric))), with = FALSE]
  </code></pre>
  
  <p>I can achieve what I want by assigning </p>
  
  <pre><code>DT2 &lt;- DT[, as.numeric(which(sapply(DT,is.numeric))), with = FALSE]
  </code></pre>
  
  <p>and then do:</p>
  
  <pre><code>DT2[is.na(DT2)] &lt;- 0
  </code></pre>
  
  <p>But of course I would like to have my original DT modified by reference. With the following, however:</p>
  
  <pre><code>DT[, as.numeric(which(sapply(DT,is.numeric))), with = FALSE]
                   [is.na(DT[, as.numeric(which(sapply(DT,is.numeric))), with = FALSE])]&lt;- 0
  </code></pre>
  
  <p>I get </p>
  
  <blockquote>
    <p>"Error in <code>[.data.table</code>([...] i is invalid type (matrix)"</p>
  </blockquote>
  
  <p>What am I missing? 
  Any help is much appreciated!!</p>