joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
220 stars 71 forks source link

moved col length checks to cover multi.panel = T as well as being num… #424

Closed ethanbsmith closed 1 month ago

ethanbsmith commented 1 month ago

moved input length checks up in flow to cover both (multi.panel == TRUE) and (is.numeric(multi.panel)) fixes #423

ethanbsmith commented 1 month ago

tbh, im not sure if we even need to check for mlti.panel. is there any harm in just doing this recycling for all scenarios?

joshuaulrich commented 1 month ago

Thanks for the PR! I just added a commit that removed some later checks on the length of 'col', 'lty', and 'lwd' so they're only in one place in plot.xts() and one place in chart.lines(). Can you test this to make sure that didn't break anything? Thanks!

ethanbsmith commented 1 month ago

hmm, im getting an error in addEventLines now. need to drill into this to isolate the issues

joshuaulrich commented 1 month ago

Can you give me an example so I can take a look too?

ethanbsmith commented 1 month ago
x <- as.xts(sample_matrix)
plot(x, multi.panel = TRUE)
addEventLines(xts("a", index(x)[10]), pos = 2:3)

seems to only be drawing on pos = 4 there seems to be a very similar variant of parameter recycling going on at the beginning of this function., but using times, not length,out

joshuaulrich commented 1 month ago

That's a bug, but not related to these changes. It's in the prior version on CRAN (0.14.0).

EDIT:

Actually, it's a bug in the example in the documentation. There's no 'pos' argument to addEventLines(). You can do what you want with the 'on' argument.

     library(xts)
     data(sample_matrix)
     sample.xts <- as.xts(sample_matrix)
     events <- xts(letters[1:3], 
                   as.Date(c("2007-01-12", "2007-04-22", "2007-06-13")))
     plot(sample.xts[,4])
     addEventLines(events, srt = 90, pos = 2)
ethanbsmith commented 1 month ago

sry, should be addEventLines(xts("a", index(x)[10]), on = 2:3) thats the error im seeing

ethanbsmith commented 1 month ago

working fine. all issues were on my end