I wonder if there is an easy way to calculate the duration. I have a dataset where the a parameter, called m, varies between the values -1 and 1 during time. I want to calculate:
- The total duration (time in hours) of cases where m=-1andm=1respectively
- How long is each period of cases where - m=-1and- m=1respectively is- m<-c(1,1,1,1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1) - Time <- seq.POSIXt(as.POSIXct(Sys.Date()), as.POSIXct(Sys.Date()+1), by = "1 hour") 
 
    