I have a data frame containing dates and for each date the number of events that took place. From this I add a field telling me if the number of events was above average or not.
Date | Events | Above Average |
---|---|---|
01/01 | 7 | 0 |
02/01 | 8 | 1 |
03/01 | 8 | 1 |
04/01 | 6 | 0 |
05/01 | 8 | 1 |
06/01 | 9 | 1 |
07/01 | 4 | 0 |
08/01 | 7 | 0 |
From this, if I perform an RLE I get
Count | Value |
---|---|
1 | FALSE |
2 | TRUE |
1 | FALSE |
2 | TRUE |
2 | FALSE |
How can I use this information to add an addition field as below to my original data frame:
Date | Events | Above Average | Run Above Av |
---|---|---|---|
01/01 | 7 | 0 | 0 |
02/01 | 8 | 1 | 2 |
03/01 | 8 | 1 | 2 |
04/01 | 6 | 0 | 0 |
05/01 | 8 | 1 | 2 |
06/01 | 9 | 1 | 2 |
07/01 | 4 | 0 | 0 |
08/01 | 7 | 0 | 0 |