0

My code:

pacman::p_load("tidyverse","tidyquant")
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
'%&%' <- function(a,b) paste(a,b)

Stocks<-c("MSFT","IWDA.AS")
D  <- tq_get(Stocks, get = "dividends", from = " 2010-01-01",complete_cases = TRUE)

The error:

Error in `dplyr::mutate()`:
ℹ In argument: `data.. = purrr::map(...)`.
Caused by error in `purrr::map()`:
ℹ In index: 2.
Caused by error in `dimnames<-.xts`:
! 'dimnames' applied to non-array
Run `rlang::last_trace()` to see where the error occurred.

The problem is that IWDA.AS has no dividend data and I get an error on that i guess. (I have actually a longer list of symbols with a few with symbols with no dividend data, not possible to eliminate them and here I give a reduced list.)

The same code worked fine 2 years ago, so I don't know what changed, something with tidyquant or yahoo finance?

Is there a quick fix for this?

(Same error occurs with 'get = "splits"'.)

gilberke
  • 45
  • 1
  • 7
  • Just set `complete_cases = FALSE`. It will ignore the stocks without dividends. You will get no error. – phiver May 17 '23 at 17:43
  • If use: D <- tq_get(Stocks, get = "dividends", from = " 2010-01-01", complete_cases = FALSE) I get the same error, so it doesn't help. – gilberke May 17 '23 at 17:51
  • Have you updated tidyquant and quantmod? Because I can't replicate your error and everything works on my side. – phiver May 18 '23 at 13:47
  • I have an updated version of R (4.3.0) & tidyquant 1.0.7, strange... I use now as a not so nice workaround a for-loop & "quantmod::getDividends" Thank you! – gilberke May 18 '23 at 17:13

0 Answers0