【问题标题】:Timeseries plotting in RR中的时间序列绘图
【发布时间】:2016-09-09 16:52:40
【问题描述】:

我在 R 中绘制时间序列数据。在 X 轴上,我应该得到 2014、2015、2016 年,而我得到的是 2014.0、2014.5、2015.0、2015.5、2016.0 和 2016.5,这很烦人.我怎样才能摆脱它?

下面是我使用的代码。

inflow<-ts(inflow,start = c(2014,1),frequency = 12)
plot(inflow, xlab="Year", ylab="Inflow Count")

谁能帮我摆脱X轴年份字段中的小数部分。我还将图像 (R Plot) 与结果输出一起附加。

【问题讨论】:

标签: r plot time-series


【解决方案1】:

这取决于输入数据或您想要绘制数据的方式。根据您的需要尝试以下几行:

data(USAccDeaths) 
USAccDeaths
plot(USAccDeaths, type="l", pch=16, cex=1, col="#425a10",bty="l", xlab="Year",ylab="Accident Deaths", main="Accident Deaths USA 1973 - 1979")

输入数据:

YEAR   Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
1973  9007  8106  8928  9137 10017 10826 11317 10744  9713  9938  9161  8927
1974  7750  6981  8038  8422  8714  9512 10120  9823  8743  9129  8710  8680
1975  8162  7306  8124  7870  9387  9556 10093  9620  8285  8466  8160  8034
1976  7717  7461  7767  7925  8623  8945 10078  9179  8037  8488  7874  8647
1977  7792  6957  7726  8106  8890  9299 10625  9302  8314  8850  8265  8796
1978  7836  6892  7791  8192  9115  9434 10484  9827  9110  9070  8633  9240

以及由此产生的情节:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多