Member-only story
The Best Way To Import Stock Market Data into R Programming— Quantmod
The Quantmod library provides a variety of functions to convert a variety of investment data into an xts time series and to calculate stock market analysis
In a separate post, I mentioned the yfR library in R Programming for downloading stock market data — it relies on Yahoo Finance information. It is a very useful and straightforward library. But there are other libraries available that can add more sophisticated features to the imported stock market data.
One of the most useful is the Quantmod library. It, and another library Quandl, can provide convenient access to investment data ready to be analyzed in a time series data object or added to a visualization. If you are working with time series data, quantmod has functions that can simplify your steps for incorporating stock prices into your project.
How Quantmod Works
The biggest difference between the yfR and quantmod libraries is the information from the functions meant to access stock prices.
The getSymbols() function can retrieve the open, high, low, and close prices of a given stock. The yfR functions only return the open and close price of a given stock.