tidyquant icon indicating copy to clipboard operation
tidyquant copied to clipboard

zoo index not recognized as POSIXct/datetime

Open kurt-o-sys opened this issue 7 years ago • 4 comments

I have a zoo object with a POSIXct index. When I try to zoom, it seems the x-values (zoo object's Index) are not recognized as a POSIXct class:

> dzoo <- as.zoo(dxts)
> candles<-tail(dzoo, nlast)
> pl <- ggplot(candles, aes(x=Index)) +
+    geom_point(aes(y=avg), cex=0.2) +
+    geom_barchart(aes(open=open, high=high, low=low, close=close),
+                  color_up="green", color_down="red") +
+    theme_tq()
> pl + coord_x_datetime(xlim=c(start, end))
Error in as.POSIXct.default(x) : 
  do not know how to convert 'x' to class “POSIXct”
> class(index(candles))
[1] "POSIXct" "POSIXt" 

What am I missing?

kurt-o-sys avatar Nov 15 '17 09:11 kurt-o-sys

Please provided a reproducible example with all code necessary to generate the issue. I can't recreate your issue currently.

mdancho84 avatar Nov 16 '17 14:11 mdancho84

please see code above... Any dzoo data with an open, close, high, low and avg field and time index will do. If that's not sufficient, ofc I can just add some random data.

kurt-o-sys avatar Nov 16 '17 20:11 kurt-o-sys

@kurt-o-sys you need to supply the dxts object so we can run your code. Can you give us the output from datapasta::tribble_paste(dxts) (even if it is a small number of rows)?

pgensler avatar Dec 09 '17 03:12 pgensler

I provided an example in https://github.com/business-science/tidyquant/issues/78 My guess is that these two issues can be merged.

ancailliau avatar Feb 22 '18 19:02 ancailliau