0
我正在嘗試編寫一個函數來爲我用「getSymbols」加載的所有股票代碼執行以下任務。我試過使用lapply,但功能似乎沒有工作。基本R功能用於加載和清理庫存數據
library(quantmod)
getSymbols(c("XLF","VFH","XLI","VIS","RWO","IYR","VNQI","VGT","RYT","VPU","IDU"), src = "yahoo",from="2012-01-01")
#NEED TO FIGURE OUT A FUNCTION FOR THIS
XLF = as.data.frame(XLF)
XLF$date = row.names(XLF)
XLI[,c("XLI.Open","XLI.High", "XLI.Low", "XLI.Adjusted")] = NULL
XLI["ticker"]="XLI"
XLI["industry"]="industrials"
colnames(XLI) <- c("date","close","volume","ticker","industry")
你似乎並沒有真正地嘗試一下 「lapply」 在這裏。什麼具體不工作?你想要這個功能的輸入是什麼,你想輸出什麼? – MrFlick