基本上,我有以下代码:
df1 <- data.frame(time=c(42688.375,42688.3784722222,42688.3819444444,42688.3854166667,42688.3888888889,42688.3923611111,42688.3958333333,42688.3993055556,42688.4027777778,42688.40625,42688.4097222222,42688.4131944444,42688.4166666667),value=c(1:13))
df2 <- data.frame(time=c(42688.375,42688.3770833333,42688.3791666667,42688.38125,42688.3833333333,42688.3854166667,42688.3875,42688.3895833333,42688.3916666667,42688.39375,42688.3958333333,42688.3979166667,42688.4,42688.4020833333,42688.4041666667,42688.40625,42688.4083333333,42688.4104166667,42688.4125,42688.4145833333,42688.4166666667),value=c(1:21))
df1[,1] <- as.POSIXct(df1[,1]*(60*60*24),origin="1899-12-30",tz="GMT")
df2[,1] <- as.POSIXct(df2[,1]*(60*60*24),origin="1899-12-30",tz="GMT")
z1 <- read.zoo(df1)
z2 <- read.zoo(df2)
z1的输出如下:
2016-11-14 09:00:00 2016-11-14 09:04:59 2016-11-14 09:09:59
1 2 3
2016-11-14 09:15:00 2016-11-14 09:20:00 2016-11-14 09:24:59
4 5 6
2016-11-14 09:29:59 2016-11-14 09:35:00 2016-11-14 09:40:00
7 8 9
2016-11-14 09:45:00 2016-11-14 09:49:59 2016-11-14 09:54:59
10 11 12
2016-11-14 10:00:00
13
z2的输出如下:
2016-11-14 09:00:00 2016-11-14 09:02:59 2016-11-14 09:06:00
1 2 3
2016-11-14 09:09:00 2016-11-14 09:11:59 2016-11-14 09:15:00
4 5 6
2016-11-14 09:17:59 2016-11-14 09:20:59 2016-11-14 09:24:00
7 8 9
2016-11-14 09:27:00 2016-11-14 09:29:59 2016-11-14 09:33:00
10 11 12
2016-11-14 09:36:00 2016-11-14 09:38:59 2016-11-14 09:42:00
13 14 15
2016-11-14 09:45:00 2016-11-14 09:47:59 2016-11-14 09:51:00
16 17 18
2016-11-14 09:54:00 2016-11-14 09:56:59 2016-11-14 10:00:00
19 20 21
请注意, z1和z2涵盖上午9点至上午10点。但是,我合并了2个动物园对象,输出突然跳到下午5点到下午6点。我期待输出显示&#34; 9 am-10am&#34;期间不是后者。
> merge.zoo(z1,z2)
z1 z2
2016-11-14 17:00:00 1 1
2016-11-14 17:02:59 NA 2
2016-11-14 17:04:59 2 NA
2016-11-14 17:06:00 NA 3
2016-11-14 17:09:00 NA 4
2016-11-14 17:09:59 3 NA
2016-11-14 17:11:59 NA 5
2016-11-14 17:15:00 4 6
2016-11-14 17:17:59 NA 7
2016-11-14 17:20:00 5 NA
2016-11-14 17:20:59 NA 8
2016-11-14 17:24:00 NA 9
2016-11-14 17:24:59 6 NA
2016-11-14 17:27:00 NA 10
2016-11-14 17:29:59 7 11
2016-11-14 17:33:00 NA 12
2016-11-14 17:35:00 8 NA
2016-11-14 17:36:00 NA 13
2016-11-14 17:38:59 NA 14
2016-11-14 17:40:00 9 NA
2016-11-14 17:42:00 NA 15
2016-11-14 17:45:00 10 16
2016-11-14 17:47:59 NA 17
2016-11-14 17:49:59 11 NA
2016-11-14 17:51:00 NA 18
2016-11-14 17:54:00 NA 19
2016-11-14 17:54:59 12 NA
2016-11-14 17:56:59 NA 20
2016-11-14 18:00:00 13 21
有人可以帮我解决这个问题吗?为什么会这样?