Ljupch0 / yfinance

Tidy Financial Statement Data in R. Via the Yahoo Finance API.
31 stars 7 forks source link

getIncome("AAPL") fails with Error: Only strings can be converted to symbols #1

Closed novica closed 4 years ago

novica commented 4 years ago

As the title says this is the error I get.

It seems to me that parse_number in the clean function fails because the dataframe has NAs and "" (empty strings?). Maybe a solution would be to turn all NA and "" to "0" and then parse_number, then convert 0 to NA. Or maybe use stringr::str_replace_na to get NA_character_.

Also as far as I can see there are some things going on in line 40: headers <- c('Items','TTM', matches[[1]][,1]) that messes the column names leaving some columns without a name. This has implications further down the code at line 62. Maybe I should've made another issue for this one.

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libopenblasp-r0.3.7.so
LAPACK: /usr/lib/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=mk_MK.UTF-8       LC_NUMERIC=C               LC_TIME=mk_MK.UTF-8       
 [4] LC_COLLATE=mk_MK.UTF-8     LC_MONETARY=mk_MK.UTF-8    LC_MESSAGES=mk_MK.UTF-8   
 [7] LC_PAPER=mk_MK.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=mk_MK.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] equityanalysis_0.1.0
Ljupch0 commented 4 years ago

From what I understand online, the error in the "Only strings can be converted to symbols" error occurs when you are trying to set something that is not a string to be the name of an object or variable. So I think both of these issues come from line 40.

NAs don't interrupt parse_number, and I removed the empty lines before running the parser.

Ljupch0 commented 4 years ago

Completely rewrote function logic, should cause no issues however it's untested on Linux.