title: Aggregate group means while ignoring zeros unless 0 is the only value
body: <p>Given the following data format:</p>
  
  <pre><code>c1 c2 c3
  A  B  100  
  A  B  200
  A  C    0
  A  C    0
  D  E  550  
  D  E  700
  D  F  100
  D  F    0
  </code></pre>
  
  <p>I want to get the mean of c3 within the group of same A and B. By using R’s <code>aggregate</code> function:</p>
  
  <pre><code>aggregate(c3~c1+c2, data=myData, FUN=mean)
  </code></pre>
  
  <p>I get the correct subset mean table:</p>
  
  <pre><code>A  B  150
  A  C    0
  D  E  625  
  D  F   50
  </code></pre>
  
  <p>Yet, I want to exclude the mean calculation for the case if there is a value and a zero. So that the last two line of the first code;</p>
  
  <pre><code>D  F  100
  D  F    0
  </code></pre>
  
  <p>should evaluate to:</p>
  
  <pre><code>D  F  100
  </code></pre>
  
  <p>Is there a way to modify the <code>aggregate</code> function? Or is there an elegant way to pre-process my data at first?</p>