I have a data.frame column with hourly values and want to count all negative values, if they are in a sequence of at least six consecutive negatives.
Example:
df <- data.frame(Values=c(-2, 2, 3, 4,-1,-1,-2,-3,
                          -1,-1,-1, 5, 4, 2,-4,-2,
                          -3,-4,-1, 3, 4, 4,-3,-1,
                          -2,-2,-3,-4))
The expected result would be 13, since the middle sequence of consecutive negatives contains only five negatives and is thus not counted.
 
     
     
    