title: Replace NA's in all data tables in a list
body: <p>I have a list containing many data tables. For each of these tables I would like to replaces the NA's with 0. </p>
  
  <p>I know how to change the NA's for each data table separately, but is there a way to put this into one command, e.g., using lapply?</p>
  
  <p>For example: li is a list containing two data table, dt1 and dt2.</p>
  
  <pre><code>li &lt;- list(dt1 = data.table(name = c(4,5), age = c(12, NA)), dt2= data.table(name = c(43,245,243), age = c(354,NA,NA)));
  </code></pre>
  
  <p>Changing the NA's to 0 in one data.table works like a charm:</p>
  
  <pre><code>d &lt;- "dt1";
  li[[d]][is.na(li[[d]])]&lt;-0;
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>&gt; li
  $dt1
    name age
  1:    4  12
  2:    5   0
  $dt2
  name age
  1:   43 354
  2:  245  NA
  3:  243  NA
  </code></pre>
  
  <p>But when I try:</p>
  
  <pre><code>test &lt;- lapply(names(li), function(d) li[[d]][is.na(li[[d]])]&lt;-0)
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>&gt; test
  [[1]]
  [1] 0
  [[2]]
  [1] 0
  </code></pre>
  
  <p>Is there any way do this without using a loop over all data tables in my list?</p>