rbind 时间序列并删除相同的日期
rbind time series and drop identical dates
x
和 y
在 2018-08-08 重叠。如何合并保留 x
的所有值的行,然后只保留不与 x
的相同 index/date 值重叠的 y
值?
x <- as.xts(1:10, Sys.Date()+1:10).
y <- as.xts(11:20, Sys.Date()+10:19).
z <- rbind(x,y)
2018-07-30 1
2018-07-31 2
2018-08-01 3
2018-08-02 4
2018-08-03 5
2018-08-04 6
2018-08-05 7
2018-08-06 8
2018-08-07 9
2018-08-08 10
2018-08-08 11
2018-08-09 12
2018-08-10 13
2018-08-11 14
2018-08-12 15
2018-08-13 16
2018-08-14 17
2018-08-15 18
2018-08-16 19
2018-08-17 20
应该缺少 y
的 2018-8-8 11 值
2018-07-30 1
2018-07-31 2
2018-08-01 3
2018-08-02 4
2018-08-03 5
2018-08-04 6
2018-08-05 7
2018-08-06 8
2018-08-07 9
2018-08-08 10
2018-08-09 12
2018-08-10 13
2018-08-11 14
2018-08-12 15
2018-08-13 16
2018-08-14 17
2018-08-15 18
2018-08-16 19
2018-08-17 20
对 y 进行子集化以忽略那些在 x 中包含索引的部分
z <- rbind(x,y[!(index(y) %in% index(x))])
x
和 y
在 2018-08-08 重叠。如何合并保留 x
的所有值的行,然后只保留不与 x
的相同 index/date 值重叠的 y
值?
x <- as.xts(1:10, Sys.Date()+1:10).
y <- as.xts(11:20, Sys.Date()+10:19).
z <- rbind(x,y)
2018-07-30 1
2018-07-31 2
2018-08-01 3
2018-08-02 4
2018-08-03 5
2018-08-04 6
2018-08-05 7
2018-08-06 8
2018-08-07 9
2018-08-08 10
2018-08-08 11
2018-08-09 12
2018-08-10 13
2018-08-11 14
2018-08-12 15
2018-08-13 16
2018-08-14 17
2018-08-15 18
2018-08-16 19
2018-08-17 20
应该缺少 y
2018-07-30 1
2018-07-31 2
2018-08-01 3
2018-08-02 4
2018-08-03 5
2018-08-04 6
2018-08-05 7
2018-08-06 8
2018-08-07 9
2018-08-08 10
2018-08-09 12
2018-08-10 13
2018-08-11 14
2018-08-12 15
2018-08-13 16
2018-08-14 17
2018-08-15 18
2018-08-16 19
2018-08-17 20
对 y 进行子集化以忽略那些在 x 中包含索引的部分
z <- rbind(x,y[!(index(y) %in% index(x))])