我有一个大的时间序列(以数据框形式)(n => 6000),如下所示:
time, precip
1 2005-09-30 11:45:00, 0.08
2 2005-09-30 23:45:00, 0.72
3 2005-10-01 11:45:00, 0.01
4 2005-10-01 23:45:00, 0.08
5 2005-10-02 11:45:00, 0.10
6 2005-10-02 23:45:00, 0.33
7 2005-10-03 11:45:00, 0.15
8 2005-10-03 23:45:00, 0.30
9 2005-10-04 11:45:00, 0.00
10 2005-10-04 23:45:00, 0.00
11 2005-10-05 11:45:00, 0.02
12 2005-10-05 23:45:00, 0.00
13 2005-10-06 11:45:00, 0.00
14 2005-10-06 23:45:00, 0.01
15 2005-10-07 11:45:00, 0.00
16 2005-10-07 23:45:00, 0.00
17 2005-10-08 11:45:00, 0.00
18 2005-10-08 23:45:00, 0.16
19 2005-10-09 11:45:00, 0.03
20 2005-10-09 23:45:00, 0.00
每行都有一个时间(YYYY-MM-DD HH:MM:SS,12 小时时间序列)和降水量。我想按风暴事件分离数据。
我想做的是:1)添加一个名为“风暴”的新列2)为每组以0分隔的金额值,称之为一个风暴。
例如...
Time, Precip, Storm
1 2005-09-30 11:45:00, 0.08, 1
2 2005-09-30 23:45:00, 0.72, 1
3 2005-10-01 11:45:00, 0.01, 1
4 2005-10-01 23:45:00, 0.08, 1
5 2005-10-02 11:45:00, 0.10, 1
6 2005-10-02 23:45:00, 0.33, 1
7 2005-10-03 11:45:00, 0.15, 1
8 2005-10-03 23:45:00, 0.30, 1
9 2005-10-04 11:45:00, 0.00
10 2005-10-04 23:45:00, 0.00
11 2005-10-05 11:45:00, 0.02, 2
12 2005-10-05 23:45:00, 0.00
13 2005-10-06 11:45:00, 0.00
14 2005-10-06 23:45:00, 0.01, 3
15 2005-10-07 11:45:00, 0.00
16 2005-10-07 23:45:00, 0.00
17 2005-10-08 11:45:00, 0.00
18 2005-10-08 23:45:00, 0.16, 4
19 2005-10-09 11:45:00, 0.03, 4
20 2005-10-09 23:45:00, 0.00
4)在那之后,我的计划是通过风暴事件对数据进行子集化。
我对 R 很陌生,所以不要害怕指出显而易见的事情。您的帮助将不胜感激!