I’m attempting to calculate the sum of consecutive values that meet the following conditions:
- Sum the value that is greater than 100 with the following values that
are equal to 480 until encountering a value different from 480 and
over 100. - And If the value after the last consecutive 480 is under 100, then stop
the sum at the last 480.
Here is a small sample of the desired results (Actual data have many rows) :
data :
test = data.frame(id = c(1:14),
X = c(0,14,12,0,150,480,480,13,18,480,14,199,480,199))
Any help would be greatly appreciated.
Thanks in advance.