我有一个月的流量的服务器日志。下面的部分示例

"UploadDateGMT","UserFileSize","TotalBusinessUnits"
"2012-01-01 00:00:38","1223","1"
"2012-01-01 00:01:16","1302","1"
"2012-01-01 00:08:10","1302","1"

我想将其转换为一个数据集,其中我可以滚动计算每五分钟窗口中提交的字节数。 (即 0-5、1-6、2-7 等)由此,我可以提取最大负载、95% 负载、制作漂亮的负载图表等。

最佳答案

扩展@PLapointe 的 answer :

endp <- endpoints(tab2, on="mins", k=1) # 1 minute endpoints
onemin <- period.apply(tab2,endp,sum)   # sum per 1-minute period
onemin <- align.time(onemin)            # align to end-of-period times
# all one-minute increments from start--end of onemin
allonemin <- seq(start(onemin), end(onemin), by="1 min")
onemin <- merge(onemin, xts(,allonemin))
fivemin <-  rollapplyr(onemin, 5, sum, na.rm=TRUE, fill=NA)

关于r - 如何在一组滚动的桶中创建一个包含数据计数的集合,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10741180/

10-10 13:32