xts可以处理具有相同时间索引的多个时间序列吗? 让我们考虑同时的数据收集: library(xts) d <- data.frame(t = Sys.time()-1:10, a = 1:10, b = 11:20 )

xts可以处理具有相同时间索引的多个时间序列吗? 让我们考虑同时的数据收集: library(xts) d <- data.frame(t = Sys.time()-1:10, a = 1:10, b = 11:20 ),r,time-series,xts,R,Time Series,Xts,有没有办法在同一时间序列中分割这两个变量?确实有办法: df.xts <- xts(cbind(d$a, d$b), order.by = d$t) df.xts df.xts <- xts(c(d$a,d$b), order.by=c(d$t,d$t)) [,1] 2018-02-16 15:13:19 10 2018-02-16 15:13:19 20 2018-02-16 15:13:20 9 2018-02-16 15:13:

有没有办法在同一时间序列中分割这两个变量?

确实有办法:

df.xts <- xts(cbind(d$a, d$b), order.by = d$t)
df.xts
df.xts <- xts(c(d$a,d$b), order.by=c(d$t,d$t))
                [,1]
2018-02-16 15:13:19   10
2018-02-16 15:13:19   20
2018-02-16 15:13:20    9
2018-02-16 15:13:20   19
2018-02-16 15:13:21    8
df.xts <- xts(cbind(d$a, d$b), order.by = d$t)