我正試圖用ggplot繪制AirPassengers的趨勢和 "原始資料",但我無法讓資料與ggplot很好地配合。我不是想找人幫我解決問題,但我需要建議,因為我遇到了難題。
代碼:
# how I am given the data set to work with
AirPassengers <- as.data.frame(AirPassengers)
# trying to get the data with a yearly trend[/span]。
AP < - ts(AirPassengers, 開始= c(1949。 1)。 頻率 = 12) #在freq = 1時不作業。
dAP < -分解(AP, type = "multiplicative")
dAP_trend <- dAP$trend
AirPassengers AP, and dAP (From the code above) don't work with ggplot. 然而,我能夠通過plot和使用:
獲得趨勢和 "原始資料 "的圖。plot(AirPassengers)
par(new=TRUE)
plot(dAP_trend, type="l"。 col="green" )
uj5u.com熱心網友回復:
通過zoo::as.zoo和time()
autoplot(as. zoo(AP)。 geom = "line")
geom_line(aes(x =) 運算子">=時間(dAP_trend)。 y = dAP_trend)。 color = "green")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/318919.html
標籤:

