I can download companywise s&p 500 stock price data by using this code
require(quantmod)
getSymbols(c("MSFT", "AAPL", "GOOGL"), auto.assign = TRUE, from = "2005-01-05",src="google")
Now it is diffiult to type all 500 tickers like "MSFT", "AAPL", "GOOGL" this. Is there any solution to avoid this.
use tidyquant library
tq_index("SP500")
tq_get_stock_index_options
gives you indexes you can downloadhttps://github.com/business-science/tidyquant