将日期和向量转换为时间序列

时间:2014-10-11 21:10:23

标签: r

我有一个单独的价格矢量(r)和日期(d)数据是有序的。我试图将价格向量转换为时间序列,指定开始和结束日期和频率。

timeprice=ts(r,start=c(2000,9),end=c(2014,8),frequency=12)

当我这样做的时候,这个系列从2001年而不是2000年开始。谁能告诉我原因?

r
 1587.62 1586.19 1573.66 1550.37 1558.89 
 1574.17 1602.98 1633.43 1664.14 1702.75

d
9/30/2000  10/31/2000 11/30/2000 12/31/2000 1/31/2001 
2/28/2001  3/31/2001  4/30/2001  5/31/2001  6/30/2001

1 个答案:

答案 0 :(得分:0)

似乎没有问题。

r = c(1587.62, 1586.19, 1573.66, 1550.37, 1558.89, 1574.17, 1602.98, 1633.43, 1664.14, 1702.75)
timeprice=ts(r,start=c(2000,9),end=c(2014,8),frequency=12)
timeprice
         Jan     Feb     Mar     Apr     May     Jun     Jul     Aug     Sep     Oct     Nov     Dec
2000                                                                 1587.62 1586.19 1573.66 1550.37
2001 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17
2002 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43
2003 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75
2004 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19
2005 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37
2006 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17
2007 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43
2008 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75
2009 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19
2010 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37
2011 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17
2012 1602.98 1633.43 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43
2013 1664.14 1702.75 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43 1664.14 1702.75
2014 1587.62 1586.19 1573.66 1550.37 1558.89 1574.17 1602.98 1633.43