'Large list to dataframe with list identification in a new column
Using the example data "hourly_time_series" from IETD package, I created a large list (each sublist are dataframes of different sizes) with IETD package. Each list represents a rainfall event.
library(IETD)
HU <- drawre(Time_series=hourly_time_series,IETD=5,Thres=0.5)
RE <- HU$Rainfall_Events
I need to convert RE to a dataframe with an additional column with the number of the rainfall event (as an ID) to separate them easily. I tried with bind_rows() and rbindlist() functions but these don´t preserve the rainfall ID. How Could I do this? The desired output as an example is:
event | Date | depth |
---|---|---|
1 | 2000-01-06 04:00:00 | 1.0 |
1 | 2000-01-06 05:00:00 | 0.0 |
1 | 2000-01-06 06:00:00 | 1.5 |
1 | 2000-01-06 07:00:00 | 1.5 |
2 | 2000-01-06 20:00:00 | 0.5 |
2 | 2000-01-06 21:00:00 | 0.5 |
. | . . | . |
. | . . | . |
. | . . | . |
Hope you could help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|