I have data like following:
time: a:
2016-02-01 16:00:00 111
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:
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
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.
What is appropriate way to do this?