使用quantmod并从Yahoo收集数据.我正在尝试获取rownames中的日期.但是我只是得到NULL.
library("quantmod")
sp500 <- new.env()
getSymbols("^GSPC", env = sp500, src = "yahoo",
from = as.Date("2008-01-04"), to = Sys.Date())
GSPC <- get("GSPC", envir = sp500)
date1 <- rownames(GSPC)
date1
> NULL
Run Code Online (Sandbox Code Playgroud)
我很感激你帮助将rowname日期变成矢量.
nog*_*pes 23
您需要使用该index功能.该xts对象与普通对象不同data.frame,并且有自己的处理维名称的方法.
# Return all dates
index(GSPC)
Run Code Online (Sandbox Code Playgroud)