title: How to delete rows where all the columns are zero
body: <p>I have the following data frame </p>
  
  <pre><code>dat &lt;- data.frame(a = c(0,0,2,3), b= c(1,0,0,0), c=c(0,0,1,3))
  </code></pre>
  
  <p>Which prints:</p>
  
  <pre><code>&gt; dat 
    a b c
  1 0 1 0
  2 0 0 0
  3 2 0 1
  4 3 0 3
  </code></pre>
  
  <p>I want to remove rows where all the columns are zeros,
  resulting in this:</p>
  
  <pre><code>  a b c
  1 0 1 0 
  3 2 0 1
  4 3 0 3
  </code></pre>
  
  <p>How can I achieve that?</p>
  
  <p>I tried this but failed:</p>
  
  <pre><code>&gt; row_sub = apply(dat, 1, function(row) all(row !=0 ))
  &gt; dat[row_sub,]
  [1] a b c
  &lt;0 rows&gt; (or 0-length row.names)
  </code></pre>