我有一个如下所示的数据集。
date <- strptime(c("2011-09-01 00:00:00","2011-09-01 06:00:00","2011-09-01 12:00:00","2011-09-01 18:00:00","2011-09-02 00:00:00",
"2011-09-02 06:00:00","2011-09-02 12:00:00","2011-09-02 18:00:00","2011-09-03 00:00:00","2011-09-03 06:00:00","2011-09-03 12:00:00",
"2011-09-03 18:00:00","2011-09-04 00:00:00","2011-09-04 06:00:00","2011-09-04 12:00:00","2011-09-04 18:00:00","2011-09-05 00:00:00",
"2011-09-05 06:00:00","2011-09-05 12:00:00","2011-09-05 18:00:00","2011-09-06 00:00:00"), format ="%Y-%m-%d %H:%M:%S")
volt <- c(7,8,9,10, 7, 8, 9, 10, 6.1, 11.1, 9.1, 10.1, 7, 8, 9, 10, 6.3, 9.4, 1.3, 19.1, 5.6)
sampV <- data.frame(date,volt)
sampV
date volt
2011-09-01 00:00:00 7
2011-09-01 06:00:00 8
2011-09-01 12:00:00 9
2011-09-01 18:00:00 10
2011-09-02 00:00:00 7
2011-09-02 06:00:00 8
2011-09-02 12:00:00 9
2011-09-02 18:00:00 10
2011-09-03 00:00:00 6.1
2011-09-03 06:00:00 11.1
2011-09-03 12:00:00 9.1
2011-09-03 18:00:00 10.1
2011-09-04 00:00:00 7
2011-09-04 06:00:00 8
2011-09-04 12:00:00 9
2011-09-04 18:00:00 10
2011-09-05 00:00:00 6.3
2011-09-05 06:00:00 9.4
2011-09-05 12:00:00 1.3
2011-09-05 18:00:00 19.1
2011-09-06 00:00:00 5.6
现在我想每天使用日期列对数据进行分组,然后检查 v 中的结果分组是否重复。例如,重复 9 月 1 日和 2 日的“伏特”数据 (7,8,9,10)。
我一直在尝试使用此代码将其拆分为不同的日子,但这是我所能做到的。
t1 <- strptime("2011-09-01 00:00:00",format="%Y-%m-%d %H:%M:%S")
t2 <- strptime("2011-09-06 00:00:00",format="%Y-%m-%d %H:%M:%S")
seqD <- seq(t1,t2, by="day")
ctD <- cut(sampV$date, seqD, labels=F )
spD <- split(sampV$date,ctD)
所以我的问题是,你如何提取那些使用重复函数或任何函数从一天到下一天复制的数据?我只是 R 的初学者,我仍在学习绳索,所以您的帮助将不胜感激。谢谢