Hi, this is a follow-up to my previous post Identifying the duration and rainfall depth of precipitation events - General - Posit Community.
In the previous forum, I identified rainfall events and created the following tibble table showing these rainfall events. In this table "rain_event" is just an identifier of the event number, i.e., the first event is 1, second event is 2, etc. "rain_event_end" is the date and time that the precipitation event ended, "hours" is the number of hours that had elapsed between the time the precipitation event started and the time the event ended, "total_precip" is the total volume of precipitation that had fallen over the rainfall event, and "avg_precip_rate" is the average precipitation rate (i.e., total_precip divided by hours).
rain_event end hours total_precip avg_precip_rate
<dbl> <dttm> <dbl> <dbl> <dbl>
1 1 2010-05-01 07:30:00 7.00 2.8 0.4
2 2 2010-05-02 00:30:00 0.25 3.0 12
3 3 2010-05-05 04:15:00 6.00 7.6 1.27
4 4 2010-05-05 17:00:00 4.00 7.2 1.8
5 5 2010-05-14 02:45:00 15.50 17.8 1.15
6 6 2010-05-14 17:45:00 2.50 0.4 0.16
7 7 2010-05-16 08:15:00 0.25 0.2 0.8
8 8 2010-05-30 18:45:00 1.25 2.4 1.92
9 9 2010-05-31 22:30:00 0.25 0.2 0.8
10 10 2010-06-01 03:00:00 0.25 0.2 0.8 `````
Using the end time of each event (end) and the duration of the event (hours) want to create another column in this tibble table for the start date and time of the event. For example, for rain_event 1, there was an end time of 2010-05-01 7:30:00 and a duration of 7 hours. This would indicate that the start time of the event was 00:00:30 (i.e., 7 hours before the event). I would like to calculate the start date and time for each event and put the data in a new table with the format
rain_event start end hours total_precip avg_precip_rate
<dbl> <dttm> <dttm> <dbl> <dbl> <dbl>
Does anyone have any advice as to how to achieve this? TIA