I was already looking for a few examples, but I did not find any filtered allowed values and their dates.
Date <-c('3/13/2017 6:21', '3/20/2017 6:28','3/13/2017 6:22','3/20/2017 6:28',' 3/13/2017 6:23','3/20/2017 6:28','3/13/2017 6:24',' 3/20/2017 6:28', ' 3/24/2017 6:28')
Enabled_value<-c(0,1,0,1,0,1,0,1,0)
Helper<-c('39RTU1','39RTU1','39RTU2','39RTU2','39RTU2','39RTU3','39RTU3','39RTU4','39RTU4', '39RTU4')
:
Helper Date(Enabled Value =0) Date (Enabled Value =1)
39RTU1 3/13/2017 6:20 3/20/2017 6:28
39RTU2 3/13/2017 6:21 3/20/2017 6:28
39RTU3 3/13/2017 6:22 3/20/2017 6:28
39RTU4 3/13/2017 6:24 3/20/2017 6:28
39RTU4 3/24/2017 6:28
As you can see, I have timestamps for each observation - each line must be an instance (i.e., go from Enabled_value from 0 to 1, and if the last Enabled_value for unit = 0, there should be a new line (see 39RTU4 below )
I have already done a great job reducing this data set (from 500 thousand to 2 thousand rows).
I try to use tidyr
and dplyr
, but mine spread
continues to work with errors.
> sorted_data1<-spread(sorted_data,Enabled_Value,Helper)
Error: Duplicate identifiers for rows (1340, 1342)