2016-08-02 34 views
1

我創建下列時間序列創建時間序列給出的時間戳和值

t = seq(as.POSIXct('2014-12-05 10:01:00'), length.out = 4, by = 'mins') 
x = c(1,3,4,2) 
y = as.ts(x,t) 

當我嘗試查看(在圖)我的時間序列,時間標籤是不是值我輸入t

plot(y) 
time(y) 
[1] 1 2 3 4 

我該如何解決?

+2

一種方法是使用'xts'類,而不是:'庫(XTS); y < - xts(x,t)' –

回答

1

我會使用xts包,即。創建時間序列爲xts對象plot.xts,而不是再利用:

library(xts) 
y.xts <- xts(x, t) 
plot(y.xts) 

enter image description here