如何在一组滚动的桶中创建一个包含数据计数的集合 [英] How to make a set containing count of data in rolling set of buckets

查看:24
本文介绍了如何在一组滚动的桶中创建一个包含数据计数的集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the server logs for a months worth of traffic. Partial example below

"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% 负载、制作漂亮的负载图表等.

I would like to convert this into a data set where I have a count of how many bytes of submissions there were in each five minute window on a rolling basis. (i.e. 0-5, 1-6, 2-7, etc.) From this, I could extract maximum load, 95% load, make pretty graphs of load, etc.

推荐答案

要扩展 @PLapointe 的 answer::>

To expand on @PLapointe's 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)

这篇关于如何在一组滚动的桶中创建一个包含数据计数的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆