Stack Financials: Analyze Financial Statement Data
A quantmod user asked an interesting question on StackOverflow: Looping viewFinancials from quantmod. Basically, they wanted to create a data.frame
that contained financial statement data for several companies for several years. I answered their question, and thought others might find the function I wrote useful… hence, this post!
I called the function stackFinancials()
because it would use getFinancials()
and viewFinancials()
to pull financial statement data for multiple symbols, and stack them together in long form. I chose a long data format because I don’t know whether the output of viewFinancials()
always has the same number of rows and columns for a given type
and period
. The long format makes it easy to put all the data in one object.