sewardlee337/finreportr

could not find function "xpath_class"

Closed this issue · 4 comments

Following errors were produced when execute provided functions

Error in do.call(method, list(parsed_selector)) :
could not find function "xpath_class"

or

Error in do.call(method, list(parsed_selector)) :
could not find function "xpath_combinedselector"

Thanks @wwni60 for reporting this issue. Can you please inform me of the specific functions you were trying to run, with the specific parameters (e.g. GetIncome(ORCL, 2015)).

Also, please provide specs for your computer and R environment. You can do so by running sessionInfo() and providing the resultant output.

Thank you!

Hello Seward,
Thank you for creating this simple and easy to use package to get financial data from SEC.
I have tried CompanyInfo(), GenIncome() and AnnualReports() on Linux Mint, they all generated similar errors.

I have also tried on Windows 10, They all work with "GOOG" as shown in example but have trouble with
another symbol "DOW" for which I own stock. CompanyInfo("DOW") and AnnualReports("DOW") worked but GetIncome("DOW", 2016) failed.

Here is the session info.

Thank you

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.1

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] dplyr_0.5.0 purrr_0.2.2 readr_1.0.0 tidyr_0.6.1
[5] tibble_1.2 ggplot2_2.2.1 tidyverse_1.1.1 curl_2.3
[9] XBRL_0.99.17 httr_1.2.1 rvest_0.3.2 xml2_1.1.1
[13] finreportr_1.0.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.9 plyr_1.8.4 forcats_0.2.0 tools_3.3.2
[5] jsonlite_1.2 lubridate_1.6.0 nlme_3.1-130 gtable_0.2.0
[9] lattice_0.20-34 psych_1.6.12 DBI_0.5-1 parallel_3.3.2
[13] haven_1.0.0 stringr_1.1.0 hms_0.3 grid_3.3.2
[17] R6_2.2.0 readxl_0.1.1 foreign_0.8-67 modelr_0.1.0
[21] reshape2_1.4.2 selectr_0.3-1 magrittr_1.5 scales_0.4.1
[25] assertthat_0.1 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.2
[29] lazyeval_0.2.0 munsell_0.4.3 broom_0.4.1

Thanks for the update, @wwni60 ! I will look into it, and update if I figure out what the bugs are.

Hi @wwni60, thank you very much for raising this issue to my attention. Here are my updates after investigating your issue...

The financials for DOW filed in 2016 (for fiscal year 2015) seem to be an edge case. For example, when I run head(GetIncome('DOW', 2017), 20), I get:

                                                                  Metric Units      Amount  startDate    endDate
1                                                           Revenue, Net   usd 58167000000 2014-01-01 2014-12-31
2                                                           Revenue, Net   usd 48778000000 2015-01-01 2015-12-31
3                                                           Revenue, Net   usd 48158000000 2016-01-01 2016-12-31
4                                                        Cost of Revenue   usd 47464000000 2014-01-01 2014-12-31
5                                                        Cost of Revenue   usd 37836000000 2015-01-01 2015-12-31
6                                                        Cost of Revenue   usd 37641000000 2016-01-01 2016-12-31
7  Research and Development Expense (Excluding Acquired in Process Cost)   usd  1647000000 2014-01-01 2014-12-31
8  Research and Development Expense (Excluding Acquired in Process Cost)   usd  1598000000 2015-01-01 2015-12-31
9  Research and Development Expense (Excluding Acquired in Process Cost)   usd  1584000000 2016-01-01 2016-12-31
10                           Selling, General and Administrative Expense   usd  3106000000 2014-01-01 2014-12-31
11                           Selling, General and Administrative Expense   usd  2971000000 2015-01-01 2015-12-31
12                           Selling, General and Administrative Expense   usd  3304000000 2016-01-01 2016-12-31
13                                     Amortization of Intangible Assets   usd   436000000 2014-01-01 2014-12-31
14                                     Amortization of Intangible Assets   usd   419000000 2015-01-01 2015-12-31
15                                     Amortization of Intangible Assets   usd   544000000 2016-01-01 2016-12-31
16                              Goodwill and Intangible Asset Impairment   usd    50000000 2014-01-01 2014-12-31
17                              Goodwill and Intangible Asset Impairment   usd           0 2015-01-01 2015-12-31
18                              Goodwill and Intangible Asset Impairment   usd           0 2016-01-01 2016-12-31
19                                                 Restructuring Charges   usd    -3000000 2014-01-01 2014-12-31
20                                                 Restructuring Charges   usd   415000000 2015-01-01 2015-12-31

But when I run GetIncome('DOW', 2016), I get the following error message:

Error in fileFromCache(file.inst) : 
  Error in download.file(file, cached.file, method = "auto", quiet = !verbose) : 
  cannot open URL 'https://www.sec.gov/Archives/edgar/data/29915/000002991516000066/dow-20151231.xml'

In addition: Warning message:
In download.file(file, cached.file, method = "auto", quiet = !verbose) :
  cannot open URL 'https://www.sec.gov/Archives/edgar/data/29915/000002991516000066/dow-20151231.xml': HTTP status was '404 Not Found'

When you actually go on the SEC EDGAR page for the DOW financial filed in 2016, and click into the XBRL instance document, you notice that the URL is different from the one listed in the error message above.

Here's a test:

> consistent_url <- 'https://www.sec.gov/Archives/edgar/data/29915/000002991516000066/dow-20151231.xml'
> inconsistent_url <- 'https://www.sec.gov/Archives/edgar/data/29915/000002991516000066/dow-20141231.xml'
> 
> consistent_url == inconsistent_url
[1] FALSE

This suggests that the SEC did not label the URL to DOW's XBRL-format financial statement filed in 2016 in a manner consistent with its general format.

Without going too deeply into the URL string structure of financials on EDGAR, this seems to be an inconsistency on the SEC's side. Thus, I do not have a solution on the finreportr side at the moment.

(I apologize if this is not a very satisfying solution to your issue. Please do let me know if there are other instances of this issue with other companies/filing years, because I am curious about how frequently this problem arises.)