I have a dataset of the activity participants are doing every hour of up to 7 days. The variables "start_clock" and "end_clock" is when participants are at work. I want to tag the time between "start_clock" and "end_clock" for each participant to be able to extract the activity exclusively in that time period. Participants can have up to three bouts of work each day, so I can't condition on the weekday. I'm able to generate spells, but I haven't found a way to tag the time when I only have the start and the endpoint. I'm hoping to get some help on how to tag the time between start_clock and the next end_clock for every particpant.
Code:
Participant_id timestamp start_clock end_clock activity 1 27oct2017 08:00:04 8 1 1 27oct2017 09:00:04 . 1 1 27oct2017 10:00:04 . 1 1 27oct2017 11:00:04 . 2 1 27oct2017 12:00:04 . 1 1 27oct2017 13:00:04 . 2 1 27oct2017 14:00:04 . 2 1 27oct2017 15:00:04 . 2 1 27oct2017 16:00:04 . 16 3 1 27oct2017 17:00:04 . 1 1 27oct2017 18:00:04 1 1 27oct2017 19:00:04 3 1 27oct2017 20:00:04 4 1 27oct2017 21:00:04 21 5 1 27oct2017 22:00:04 4 1 27oct2017 23:00:04 23 2 2 28oct2017 00:00:04 1 2 28oct2017 01:00:04 1 2 28oct2017 02:00:04 2 2 28oct2017 03:00:04 3 2 28oct2017 04:00:04 3 2 28oct2017 05:00:04 3 2 28oct2017 06:00:04 3 2 28oct2017 07:00:04 3 2 28oct2017 08:00:04 8 3 2 28oct2017 09:00:04 4 2 28oct2017 10:00:04 4 2 28oct2017 11:00:04 11 2

Comment