title: Aggregation in time intervals - R language
body: <p>I have data like following:</p>
  
  <pre><code>    time:                   a:
      2016-02-01 16:00:00      111
  </code></pre>
  
  <p>The value of column "a" could be any number and NA. For each "time" number/NA is assigned to "a".
  The data is ordered by "time" ascending.
  My task is to aggregate periods when the "a" equals NA (R language).
  Examplary data set:</p>
  
  <pre><code>     2016-02-01 16:00:00 NA
       2016-02-01 16:00:01 NA
       2016-02-01 16:00:02 NA
       2016-02-01 16:00:03 NA
       2016-02-01 16:00:04 21
  </code></pre>
  
  <p>So there are 4 "NA" values in a row and it takes 4 seconds. So it should be aggregate to interval 0 - 15 sec. The original dataset has about 100000 records and each interval of NA values should be aggregated in the same way.
  Intervals are not equal, it starts with 0-15 sec and ends with 1-2 days.</p>
  
  <p>What is appropriate way to do this?</p>