这是apcpDW = setDT(apcpDW)[, RAIN := cumsum(wm), by = rleid(wday == 2)]
:
timestamp wm wday RAIN
1: 1998-01-01 0.000000000 5 0.000000000
2: 1998-01-02 0.005644862 6 0.005644862
3: 1998-01-03 1.580885557 7 1.586530419
4: 1998-01-04 7.033152468 1 8.619682888
5: 1998-01-05 8.254771325 2 8.254771325
6: 1998-01-06 7.309265805 3 7.309265805
7: 1998-01-07 8.914006707 4 16.223272512
8: 1998-01-08 13.836810823 5 30.060083334
9: 1998-01-09 5.516107500 6 35.576190834
10: 1998-01-10 0.201572931 7 35.777763765
为什么在wday
2
和3
之间不能继续运行总和?它会在2
之前重置,然后在2
之后重新重置。我需要更改哪些内容才能获得wm
从2
到下一个1
的总和? (即,wday
1
将始终具有最大值,后续2
将完全为wm
,然后3
将为2+3
......等等)