[英]How to plot 3D time series in R with lagged version
我在這里很新,所以我不太熟悉大多數命令。
我想用x軸上的數據,z上的滯后序列以及y上的時間變量來創建3D圖。 我目前正在使用密謀,但它給了我奇怪的結果。 我的代碼中是否有任何錯誤,還是我使用的軟件包錯誤? 我的數據是從1997年1月到2018年8月的出口。
到目前為止,這是我的代碼。
library(readxl)
Export <- read_excel("C:/Users/Alecsandra/Downloads/Export.xlsx")
export <- ts(Export, start=c(1997, 1), end=c(2018, 8), frequency=12)
export1 <- ts(export[-1], start=c(1997, 1), end=c(2018, 7), frequency=12)
#Plotly said Z variable needs to be matrix so i made my time variable matrix
Time <- matrix(ncol=10, nrow=26)
Time[] <- seq(1, 260, by = 1)
plot_ly(x = export1, y = export, z = Time) %>% add_surface()
這是我的結果:
不確定要做什么,但這可能是個提示,即使不是ts對象也是如此:
library(rgl)
t <- seq(100)
x <- cumsum(rnorm(length(t))
y <- lag(x)
plot3d(x,y,t)
lines3d(x,y,t, new=T, col=colorRampPalette(c("red", "grey80","blue"))(100)[t])
基本上看一下rgl包和plot3d等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.