Hi I am currently doing this in R but would like to know if there is a way for me to do it in Flux instead:
I have a time series that tracks a value and only stores when the signal is turned on and off. The problem is that the nature of the machine I am tracking only allows for it to be done this way. This results in a data table/measurement where two rows kind of display a single value (e.g. the start and end of a Fault). How do I query the data using flux to combine those two rows? (With "start" and "stop" as tags/fields)
I currently use the elapsed()
-function to calculate the time difference/duration of my value
time value field measurement equipmentNumber workplace duration
2021-01-29 07:11:17.496 1 FAULT_LASER FAULT_LASER L5211M0855 0 188
2021-01-29 07:12:03.332 0 FAULT_LASER FAULT_LASER L5211M0855 0 45835
2021-01-29 07:12:19.618 1 FAULT_LASER FAULT_LASER L5211M0855 0 16285
2021-01-29 07:12:19.618 0 FAULT_LASER FAULT_LASER L5211M0855 0 161725
Im am doing this in R at the moment:
for(i in 1:nrow(df_f)){
if(df_f[i, "duration"] > 0){
df_fdur[i, "start"] <- df_f[i, "time"]
df_fdur[i, "stop"] <- df_f[i+1, "time"]
df_fdur[i, "type"] <- df_f[i, "value"]
df_fdur[i, "duration"] <- df_f[i, "duration"]
df_fdur[i, "workplace"] <- df_f[i, "workplace"]
df_fdur[i, "equipmentNumber"] <- df_f[i, "equipmentNumber"]
}
}
Any ideas on how I can do that?
This does not directly solve the question but it solved the problem I was working on. Maybe it is useful for someone else. Have a great day!