How To Import Stock Market Price Data into R Programming

The yfR library can import stock data from Yahoo! Finance

Pierre DeBois
5 min readMar 12, 2023
Image created on MidJourney by Pierre DeBois

Stock performance is a great way of examining time series data, as well as understanding the mechanics of creating forecasts. The volatility of stock can teach how to examine patterns in a time series analysis as well as build some speculation for those who are trading in stock, casual or otherwise. ;-)

Within R programming, one library offers a simple way to apply these concepts. It is called yfR. yfR is a R programming library designed to extract stock market data from the Yahoo! Finance site.

This library is very unique in that there is no current Google finance counterpart. Google decommissioned the access to its Google Finance API, leaving Yahoo! finance as the main API for downloading stock market data into software applications. Fortunately for financial analysts and savvy stock pickers, this library is very straightforward to use, with seven functions featured in the supporting CRAN documentation.

When using the library, two functions are really the most important to know — — yf_get() and yf_collection_get(). Both are the main functions for downloading stock market data.

--

--

Pierre DeBois

#analytics |#datascience |#JS |#rstats |#marketing services for #smallbiz | #retail | #nonprofits Contrib @CMSWire @smallbiztrends #blackbusiness #BLM