I am trying to convert multiple xts objects in the Global environment to be multiple data.frames of the same name. I am trying to create a array of data.frames that can be feed into a program.
My code creates the xts objects OK but I would have to go back an manually convert each xts object for example (LMT <- as.data.frame(LMT)
). I am looking to do a 100 or stocks at a time so this would be a great time saver. I was able to create its stock its objects for the example below in the list for tickers.
My code is as follows
require(quantmod)
require(xts)
tickers <- c("REGN", "LMT", "ZN", "OXY", "PG", "WBA", "EXC")
FromDate = "2011-01-01"
ToDate = "2015-08-07" #Set one day ahead
getSymbols(tickers, from = FromDate, to = ToDate, src="yahoo")
###Convert to Data Frame
stocks[ticker] <- as.data.frame (c("REGN", "LMT", "ZN", "OXY", "PG", "WBA", "EXC")
Any suggestions would be helpful.