I work on a code to collect data from the S&P500. I do get the data I need, but now I have for each stock a xts object that I want to convert to one big data.frame, so I can run an event study or create a chart.
url <- "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
tables <- getURL(url)
tables <- readHTMLTable(tables, stringsAsFactors = F)
sp500symbols <- tables[[1]][,1:2]
head(sp500symbols)
rm(list="tables", "url")
tix <- c(sp500symbols$`Ticker symbol`)
quantmod_list = tix
for(company in quantmod_list) {
try(getSymbols(company, from="2009-12-29", to="2009-12-30"))
print(company)
}