I want to compute the percentage of the durations a system is deactivated. The activation is given in a column "Active" where 1 means Activation and 0 means deactivation. The observations (rows) correspond to different readings from different systems identified by their "ID". The "Time" of each reading is identified in timestamps. Here is a sample of the data I have in a tibble.
ID Timestamp Active
64 1512743947 1
74 1512743963 1
76 1512743978 1
80 1512743992 0
22 1512744041 1
74 1512744155 1
80 1512744175 1
51 1512744240 1
80 1512744266 0
80 1512744275 1
I followed the response to my question here: Extract change duration in R. But I figured out that the sum of the timestamps difference won't get me to where I want to be. So to be clear, as a response I would like to have the total percentage of time each ID spent deactivated which means between 0 and 1 (not 1 and 0).
ID Percentage
80 67%