This project primarily intends to build a universal xbrl instance reader in R. However we might add a few functions specific to national or international taxonomies eg. DK(erst), US(SEC)
Right now you can only install from the github sources:
devtools::install_github("soetang/xbrlr")
library("xbrlr")
# first download the xbrl file
uri = "https://datacvr.virk.dk/data/offentliggorelse?dl_ref=ZG9rdW1lbnRsYWdlcjovLzAzL2YxL2NhLzVlLzNmLzFkYmYtNGRmNC04ZDk2LTI1MGI2YTJlNzY1YQ"
xml_doc <- httr::GET(url = uri) %>% httr::content()
# then create the xbrl instance
xbrl_instance <- xbrl(xml_doc)
# now you can access the three tables that make up the instance
xbrl_instance$facts
xbrl_instance$units
xbrl_instance$contexts
Note that we currently dont support footnotes but gladly accepts pull requests
Here we created a function to join units and context onto the facts table
xbrl_table <- to_one_table(xbrl_instance)
We have build helper functions to get the facts regarding the specific period of XBRL the document for:
- Danish get_this_period_dk
- German get_this_period_de
Continuing the example from above:
this_year <- get_this_period_dk(xbrl_table)
Example for German XBRL
de_example <- get_example("de") %>%
file() %>%
xml2::read_xml() %>%
xbrl() %>%
to_one_table() %>%
get_this_period_de()
However in order to parse xbrl files you need to access the files first. Here we provide direct access to danish reports.
Below we collect links to all reports published today, and filter away any without xbrl
pubs_from_today <- query_api_dk(as.character(Sys.Date())) %>%
dplyr::filter(xml_link != "")
This project draws inspiration from XBRL-AI - xbrl for ml in python and XBRLfiles which uses the r XBRL package which is primarily aimed at SEC data. Parsing using the XBRL library fails if taxonomy files are not avaiable, in this project the goal is that parsing should only use the xbrl instance without outside dependencies.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.