4

I've been trying to isolate income statements, balance sheets, and cash flow data from the sec website using the XBRL package in R. Ideally, I would input the three into separate data frames with the hopes of exporting the data to a uniform product in excel.

I am able to print out the statements in the R console with the following commands:

inst <- "http://www.sec.gov/Archives/edgar/data/1223389/000122338914000023/conn-20141031.xml"
options(stringsAsFactors = FALSE)
xbrl.vars <- xbrlDoAll(inst)
xbrl.sec <- xbrlSECdev01(xbrl.vars)
xbrl.sec$showStatements()

but I am unable to create a data frame to hold all this information.

So far, I've tried:

conn.data <- xbrl.sec$showStatements()

Unfortunately, this just prints out the data again and leaves conn.data NULL.

Any idea how to store this data?

"How to take the lists created by xbrlDoAll in the XBRL package in R, and organize them into dataframes readable in Excel?" was asked last March and was left unanswered.

Community
  • 1
  • 1
Alan Felix
  • 51
  • 1
  • 3

1 Answers1

5

XBRL package is a parser for complex XBRL files (XML, schemas, XLinks, ...). The result is simple: a list of data frames. But it still requires some understanding of XBRL philosophy.

You will find all the numbers in the fact table. By joining the context you get the period and specific dimensions. To know which accounting concepts they represent (cash, inventory, current assets, etc.) you have to join the element table as well.

Elements are usually hierarchically arranged by 3 link bases: calculation, presentation and definition. Link bases use from-element and to-element fields to define hierarchy and rule to separate different views. The financial statements are usually described in presentation link base.

Finally - use label table to look-up concept names and descriptions (they are linked directly from elements but may have more label types and languages).

The whole thing is more or less an exercise in joining the tables in the right order, so dplyr comes in very handy. You can see my struggle with a sample SEC file on github.

bergant
  • 7,122
  • 1
  • 20
  • 24