My code is by quantmod to get stock data from Yahoo wit getSymbols. Tools is RStudio and Quantmod 0.40.2
getSymbols("000001.SZ", src="yahoo",from="1900-10-01", to = Sys.Date(), auto.assign = TRUE )
View(000001.SZ)
There is no problem to AAPL stock data.
getSymbols("AAPL", src="yahoo",from="1900-10-01", to = Sys.Date(), auto.assign = TRUE )
View(AAPL)
I can get data stock data, but cannot view it.
How to solve the issue? Is it the stock name problem? Fix the issue and to view the data.
The name "000001.SZ" is not supported in R. From the documentation ?make.names
A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. Names such as ".2way" are not valid, and neither are the reserved words.
As you can see, it is not valid to start a name with a number. Instead save the data into a different variable name and it will work.
library(quantmod)
dat <- getSymbols("000001.SZ", src="yahoo",from="1900-10-01", to = Sys.Date(), auto.assign = FALSE)
View(dat)