我用R的tidyquant抓取S&P500里面的某几个个股数据。
install.packages(c("tidyquant","dplyr","tidyverse"))
library(tidyquant)
library(dplyr)
library(tidyverse)
tq_index("SP500")
stock_symbols <-c("NVDA","TSLA","META")
start_date <- "2018-03-24"
end_date <- "2023-03-24"
stock_prices <- stock_symbols %>%
tq_get(get = "stock.prices",
from = start_date,
to = end_date,
collapse = "daily")
print(stock_prices)
```r
跑动后,系统报错,显示如下
```r
Warning message:
There were 3 warnings in `dplyr::mutate()`.
The first warning was:
ℹ In argument: `data.. = purrr::map(...)`.
Caused by warning:
**! x = 'NVDA', get = 'stock.prices': Error in getSymbols.yahoo(Symbols = "NVDA", env = <environment>, verbose = FALSE, : Unable to import “NVDA”.
$ operator is invalid for atomic vectors
Removing NVDA.
ℹ Run dplyr::last_dplyr_warnings() to see the 2 remaining warnings.
这个该怎么解决呢