I'm trying to randomly select 50 stocks from the New York Stock Exchange, and then get the symbols for them. This code:
require(quantmod)
NYstocks<-stockSymbols(exchange="NYSE")
NYsymbols<-NYstocks[["Symbol"]]
my_portfolio<-sample(NYsymbols, 50, replace = FALSE)
date_begin <- as.Date("2014-02-18")
date_end <- as.Date("2016-02-18")
tickers <- getSymbols(my_portfolio, from = date_begin, to = date_end)
gets the error
Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names
my_portfolio is a character vector, so I'm having a hard time figuring out what it means about columns and column names. I've tried using src="google" and got
Error in
colnames<-(*tmp*, value = c("AIW.Open", "AIW.High", "AIW.Low", : length of 'dimnames' [2] not equal to array extent
Thanks for any help!