I'm running a portfolio optimization and to do that I want to download historical stock data using the stockPortfolio package. I ran the below code, which should generate the pricing data from Yahoo Finance. Instead, I'm getting an error:
```{r}
stocks <- c("AAPL")
getReturns(ticker = stocks, freq = "year")
```
Here's the traceback:
Error in file(file, "rt") : cannot open the connection
4.file(file, "rt")
3.read.table(file = file, header = header, sep = sep, quote = quote, dec = dec, fill = fill, comment.char = comment.char, ...)
2.read.delim(URL, TRUE, sep = ",")
1.getReturns(ticker = stocks, freq = "year")
Looking around other threads, I can't find a great answer. I have the latest version of R and updating my proxy settings doesn't do anything.