I am trying to solve the very basic example and trying to extract following data:
count SN data.stamp
1 00601 2018-07-26 13:38:39
0 00601 2018-11-05 23:00:09
0 00601 2018-11-05 23:00:16
4 00601 2018-11-12 23:00:05
0 00601 2018-12-12 23:00:05
5 00601 2018-11-12 23:00:05
0 00601 2018-12-12 23:00:05
0 00601 2018-11-12 23:00:05
0 00601 2018-12-12 23:00:05
Expected output:
count SN data.stamp
1 00601 2018-07-26 13:38:39
0 00601 2018-11-05 23:00:09
4 00601 2018-11-12 23:00:05
0 00601 2018-12-12 23:00:05
5 00601 2018-11-12 23:00:05
0 00601 2018-12-12 23:00:05
I would like to consider only single count with 0
value. If there are multiple count of 0
values then it should consider only first value and ignore rest of 0
counts.
Basically, I am looking for only first zero value followed by non zero value.
I tried using rle
but I would like to extract data from the data.frame
. rle
can give me information about the values and lengths. I can write for
loop to check but looking for a quick and short way.