为什么R中时间序列图的x轴值显示2012.0、2013.0而不是2012年1月等?
我创建了一个时间序列矩阵,其代码和输出如下:为什么R中时间序列图的x轴值显示2012.0、2013.0而不是2012年1月等?,r,time-series,timeserieschart,R,Time Series,Timeserieschart,我创建了一个时间序列矩阵,其代码和输出如下: ts2 <-ts(cbind(LRC_3PDMUM, LRC_3PDMMS),frequency=12,start=c(2012,1)) ts2 LRC_3PDMUM LRC_3PDMMS Jan 2012 0.029256 0.025904 Feb 2012 0.051945 0.055827 Mar 2012 0.078153 0.084049 Apr 2012 0.100596 0.110
ts2 <-ts(cbind(LRC_3PDMUM, LRC_3PDMMS),frequency=12,start=c(2012,1))
ts2
LRC_3PDMUM LRC_3PDMMS
Jan 2012 0.029256 0.025904
Feb 2012 0.051945 0.055827
Mar 2012 0.078153 0.084049
Apr 2012 0.100596 0.110188
May 2012 0.126015 0.136850
Jun 2012 0.149349 0.162446
Jul 2012 0.173949 0.186486
Aug 2012 0.198704 0.212683
Sep 2012 0.220277 0.237433
Oct 2012 0.244358 0.262342
Nov 2012 0.272664 0.286019
Dec 2012 0.293653 0.309429
Jan 2013 0.320472 0.331575
Feb 2013 0.339880 0.356900
Mar 2013 0.362203 0.384612
Apr 2013 0.383525 0.408996
May 2013 0.403316 0.431810
Jun 2013 0.430651 0.454040
Jul 2013 0.453148 0.475161
Aug 2013 0.484378 0.496460
Sep 2013 0.501923 0.518307
Oct 2013 0.525252 0.541631
Nov 2013 0.544958 0.563007
Dec 2013 0.564571 0.582775
但是,当我绘制2号图时,该图的x轴值为2012.0、2013.0,而我预期的值为2012年1月、2013年2月等。请告知如何修改代码。谢谢 假设一个与您类似的示例:
a <- ts( matrix(1:100,ncol=2), frequency = 12, start = c(1959, 1))
> a
Series 1 Series 2
Jan 1959 1 51
Feb 1959 2 52
Mar 1959 3 53
Apr 1959 4 54
May 1959 5 55
Jun 1959 6 56
Jul 1959 7 57
Aug 1959 8 58
Sep 1959 9 59
Oct 1959 10 60
Nov 1959 11 61
Dec 1959 12 62
Jan 1960 13 63
Feb 1960 14 64
#and so on...
library(xts)
#transform to xts that uses this date format
b <- as.xts(a)
#plot first series
plot (b[, 'Series 1'], ylim=c(0,100))
#plot second series
lines(b[, 'Series 2'], col='red')