I am using tidyquant to get several stocks prices, and here are my codes.
install.packages(“tidyquant")
install.packages(“dplyr")
library(tidyquant)
library(dplyr)
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)
after I run, received warning messages as below:
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 = , verbose = FALSE, : Unable to import “NVDA”.
$ operator is invalid for atomic vectors
Removing NVDA.
how can I fix it?
pls help me!