Search code examples
rdygraphs

Dygraphs in R with numeric x axis


My question is with reference to this issue here.Seeing that dygraph now supports numeric x axis I tried to test a data with numeric x axis however it gave an error. The code that I used is

 dygraph(as.data.frame(x = 1:10, y = runif(10))) %>%
  dyAxis("y", valueRange = c(0, 1.5)) %>%
  dyEvent(2, label = "test") %>%
  dyAnnotation(5, text = "A")

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format

Solution

  • you were very close; replace as.data.frame with data.frame

     dygraph(data.frame(x = 1:10, y = runif(10))) %>%
      dyAxis("y", valueRange = c(0, 1.5)) %>%
      dyEvent(2, label = "test") %>%
      dyAnnotation(5, text = "A")