在新列中使用列表标识的数据帧的大列表
使用IETD软件包中的示例数据“ hourly_time_series”, 我使用IETD软件包创建了一个大列表(每个子列表都是不同尺寸的数据范围)。每个列表代表一个降雨事件。
library(IETD)
HU <- drawre(Time_series=hourly_time_series,IETD=5,Thres=0.5)
RE <- HU$Rainfall_Events
我需要将RE转换为带有额外列的数据框架,其中包含降雨事件的数量(作为ID),以轻松将它们分开。 我尝试使用bind_rows()和rbindlist()函数尝试,但这些函数不保留降雨ID。 我该怎么做?所需的输出为:
事件 | 日期 | 深度 |
---|---|---|
1 | 2000-01-06 04:00:00 | 1.0 |
1 | 2000-01-06 05:00:00 | 0.0 0.0 |
1 | 2000-01-06-06 06:00:00 | 1.5 |
1 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 0.5 |
。 | 。 。 | 。 |
。 | 。 。 | 。 |
。 | 。 。 | 。 |
希望你能帮忙
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将定义一个用于演示的示例数据集,一个名为
ll
的列表,其中五个元素是一个带有两个字段的数据框,date
anddepth 。每个列表元素都有一个唯一的名称,例如
event1
,event2
等。您可以在每个子列表中添加一个ID字段,然后将列表折叠到单个数据框中:
I'll define an example dataset for demonstration, a list called
ll
with five elements, each of which is a dataframe with two fields,date
anddepth
. Each list element has a unique name, egevent1
,event2
, etc.You could add an ID field to each sublist and then collapse the list into a single dataframe: