xts 包可以解决问题:
library(xts)
tab <-read.table(text="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", header=TRUE, as.is=TRUE,sep = ",")
tab2<-xts(tab$UserFileSize,order.by=as.POSIXct(tab$UploadDateGMT) ) #create xts object
endp <-endpoints(tab2, on="mins", k=5) #5 minutes endpoints
fivemin <-period.apply(tab2,endp,sum) #sum per 5-minute period
fivemin
[,1]
2012-01-01 00:01:16 2525
2012-01-01 00:08:10 1302
如果您希望时间列以 5 分钟为增量:
res<- align.time( fivemin[endpoints(fivemin, on="mins", k=5)], n=60*5)