2
骨料中的R数据帧我想通过时间来汇总数据,并创建等间隔的时间间隔:通过等距的时间间隔
date<- c(as.POSIXct("2011-08-08 21:00:00"), as.POSIXct("2011-08-08 21:26:00"))
value<-c(1,2)
dt<-data.frame(date, value)
DT<-aggregate(cbind(dt$value),list(cut(dt$date, breaks="10 min")),sum)
dt:
2011-08-08 21:00:00 1
2011-08-08 21:26:00 2
DT:
2011-08-08 21:00:00 1
2011-08-08 21:20:00 2
我想要什么:
2011-08-08 21:00:00 1
2011-08-08 21:10:00 NA
2011-08-08 21:20:00 2
反正是有做到这一点,而不使用动物园或xts?