title: R: Counting number of consecutive hours per day, month, and year
body: <p>I have researched and tried many things. I am already using dplyr, tidyr, data.table, lubridate, and sqldf packages in my script.</p>
  <p>Here is part of my <a href="https://i.stack.imgur.com/JI623.png" rel="nofollow noreferrer">dataframe</a>. I am trying to count how many consecutive hours occur per day, month, and year. Some days may have two consecutive sets, such as 2 hours and 4 hours. I would like all consecutive hours, not just the maximum per day.</p>
  <p>Ideally, the final dataframe will have year, month, day, and number of consecutive hours. Thanks in advance!</p>
  <p>Here is the code I currently have which gives me doubles and only the max:</p>
  <pre><code>consec &lt;- df1 %&gt;%
    add_count((hour)!= 1, name = 'Count') %&gt;%
    group_by(year,month,day) 
  </code></pre>