title: Replacing zero values in table A with non-zero values in table B if available
body: <p>I have data as follows:</p>
  <pre><code>tableA &lt;- structure(c(0L, 0L, 6L, 0L, 6L, 0L, 3L, 0L, 0L), dim = c(3L, 
  3L), dimnames = structure(list(c(&quot;0.3&quot;, &quot;0.4&quot;, 
  &quot;0.6&quot;), c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;)), names = c(&quot;&quot;, &quot;&quot;)), class = &quot;table&quot;)
  
        A B C
    0.3 0 0 3
    0.4 0 6 0
    0.6 6 0 0
  
  tableB &lt;-structure(c(0L, 1L, 2L, 0L, 3L, 0L, 3L, 2L, 0L), dim = c(3L, 
  3L), dimnames = structure(list(c(&quot;0.3&quot;, &quot;0.4&quot;, 
  &quot;0.6&quot;), c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;)), names = c(&quot;&quot;, &quot;&quot;)), class = &quot;table&quot;)
  
        A B C
    0.3 0 0 3
    0.4 1 3 2
    0.6 2 0 0
  </code></pre>
  <p>I would like to replace all zeroes in <code>tableA</code> with positive values in <code>tableB</code> if they are available and somehow mark them.</p>
  <p>What would be the easiest way to achieve this?</p>
  <p>Desired output:</p>
  <pre><code>      A B C
    0.3 0 0 3
    0.4 1 6 2
    0.6 6 0 0
  </code></pre>
  <p>The added issue is that I would somehow like to know which values were replaced, but that seems difficult to realise.</p>