[英]Aggregating Time Series data by 15 minutes
I have looked at many of the questions on here that relate to aggregating time series data, but I can't seem to solve my problem. 我在这里看了很多关于聚合时间序列数据的问题,但我似乎无法解决我的问题。 My data looks like this:
我的数据如下:
Pings Adult Entertainment Female Information Lifestyle Male MAV.TV MeTV News Pursuit Sports Young Adult
2015-01-05 07:30:00 1 0 0 0 0 0 0 0 0 0 0 0 0
2015-01-05 07:43:00 1 0 0 0 0 0 0 0 0 0 0 0 0
2015-01-05 07:44:00 1 0 0 0 0 0 0 0 0 0 0 0 0
2015-01-05 07:59:00 5 0 0 0 0 0 0 0 0 0 0 0 0
2015-01-05 08:02:00 1 0 0 0 0 0 0 0 0 0 0 0 0
2015-01-05 08:17:00 1 0 0 0 0 0 0 0 0 0 0 0 0
and I want to find a way to roll this up in 15 minute increments, summing every row. 我想找到一种方法以15分钟的增量滚动它,总结每一行。 I've tried
merge
and cut
and aggregate
and na.locf
methods, but none of them quite work. 我已经尝试了
merge
和cut
以及aggregate
和na.locf
方法,但它们都没有完全奏效。 I've also tried period.apply
but I can't seem to get that to work. 我也尝试过
period.apply
但我似乎无法period.apply
工作。
对于timebreak = ISOdatetime(2015, 1, 5, 7, 0, 0) + (seq(0,7)*15*60)
,我使用fac = cut(time(data), breaks = timebreak)
然后aggregate(data, by = fac, FUN = sum)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.