title: Count consecutive occurrences of a specific value in every row of a data frame in R
body: <p>I've got a <code>data.frame</code> of monthly values of a variable for many locations (so many rows) and I want to count the numbers of consecutive months (i.e consecutive cells) that have a value of zero. This would be easy if it was just being read left to right, but the added complication is that the end of the year is consecutive to the start of the year.</p>
  
  <p>For example, in the shortened example dataset below (with seasons instead of months),location 1 has 3 '0' months, location 2 has 2, and 3 has none.</p>
  
  <pre><code>df&lt;-cbind(location= c(1,2,3),
  Winter=c(0,0,3),
  Spring=c(0,2,4),
  Summer=c(0,2,7),
  Autumn=c(3,0,4))
  </code></pre>
  
  <p>How can I count these consecutive zero values? I've looked at <code>rle</code> but I'm still none the wiser currently!</p>
  
  <p>Many thanks for any help :) </p>