簡體   English   中英

如何在R中的時間序列的x軸上刪除小數值

[英]how to remove fractional value in x-axis of timeseries in R

我想用以下代碼生成一個時間序列:

Chlorophyll_data<-read.csv("Chlorophyll.csv", header = T)
#create a timeseries object which has built in functionality 
Chlorophyll.ts <- ts(Chlorophyll_data$Chlorophyll, frequency=12, start=c(2014,1)) 
plot.ts(Chlorophyll.ts, format = "%Y")
Chlorophyll.components <- decompose(Chlorophyll.ts)
plot(Chlorophyll.components, format="%Y")

該圖看起來像這個時間序列分解

但是曲線圖的x軸顯示年份的分數。 有人可以告訴我如何刪除分數值嗎?

我的數據是:

Year  Month Chlorophyll
2014    1   55.33462
2014    2   85.79968
2014    3   75.10592
2014    5   66.46263
2014    6   84.44795
2014    7   77.94365
2014    8   114.8308
2014    9   67.64554
2014    10  92.86682
2014    11  112.0653
2015    1   39.25982
2015    2   51.15999
2015    3   55.7578
2015    4   67.80606
2015    6   60.78814
2015    7   69.00764
2015    8   64.76438
2015    9   57.52195
2015    11  73.32797
2015    12  31.36951
2016    1   61.07596
2016    2   50.15889
2016    3   93.3778
2016    4   103.4554
2016    5   106.4145
2016    6   77.07053
2016    7   70.27304
2016    8   62.89573
2016    9   76.19891
2016    10  86.45399
2016    11  70.48216
2016    12  40.78854

謝謝。

一種方法是簡單地離開x軸,然后使用axis函數將其放到自己身上。

plot(Chlorophyll.components, xaxt="n")
axis(side=1, at=2014:2017, line=1.1)

手動軸

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM