Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Compute activity blocks coming from IoT device

$
0
0

Here is a toy data.

datetime <- c('2019-11-06 13:05:07',
'2019-11-06 13:05:08',
'2019-11-06 13:05:09',
'2019-11-06 13:05:10',
'2019-11-06 13:05:11',
'2019-11-06 13:05:12',
'2019-11-06 13:05:13',
'2019-11-06 13:05:14',
'2019-11-06 13:05:15',
'2019-11-06 13:05:16',
'2019-11-06 13:05:17',
'2019-11-06 13:05:18',
'2019-11-06 13:05:19',
'2019-11-06 13:05:20',
'2019-11-06 13:05:21',
'2019-11-06 13:05:22')

active <- c(1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0)

df <- data.frame(datetime, active)

I am looking for a vectorize code that will compute the activity blocks. In the above example we have 2 activity blocks.

  1. 13:05:07 - 13:05:10
  2. 13:05:16 - 13:05:20

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>