0
我使用的sp500ret數據從rugarch包:如何在情節中將rownames繪製爲日期?
library(rugarch)
data(sp500ret)
這(至少我想是這樣)一個數據幀,其給出的回報率。 rownames是日期。現在,我要繪製的回報和日期,所以
plot(dates,sp500ret)
當然的,但是,這是行不通的,因爲日期沒有指定,但我怎麼能使用rownames爲相應的日期?
注:我不知道這件事,但我讀了一些關於xts文件的內容。這是一個xts文件,我怎麼能在這種情況下繪製它?
編輯: 我想過這樣的事情,但它不工作:
plot(as.Date(rownames(sp500ret), "%Y%m%d"),sp500ret)
2日編輯: 也plot(rownames(sp500ret),sp500ret[,1])
不起作用。
我現在也發現:圖(as.Date(rownames(sp500ret),「%Y - %m-%d「),sp500ret [,1])這似乎也起作用了? –
@StatTistician是的,這也是訣竅。 – COOLSerdash
las = 1做什麼? –