1

I have a time-series of quantitative and qualitative data. I am trying to plot a time-series of the data with dyGraphs, but I also want to be able to view the qualitative data when I hover over a certain point.

Something like this:

library(shiny)
library(dygraphs)
library(xts)

my_data <- data.frame("date" = ymd(c("2020-01-01", "2020-02-01", "2020-03-01")),
                      "quan1" = c(1, 2, 3),
                      "quan2" = c(6, 5, 4),
                      "qual1" = c("a", "b", "c"),
                      "qual2" = c("f", "e", "d"))

ui <- fluidPage(
  dygraphOutput("mygraph")
)

server = function(input, output, session) {
  output$mygraph <- renderDygraph({
    my_data_xts <- xts(x = my_data, order.by = my_data$date)
    dygraph(my_data_xts, main = "My Graph") #%>%
      #something like: dyHover("qual1", "qual2") ???
  })
}

shinyApp(ui = ui, server = server)

When I run this, the graph seems to recognise that the qualitative series are included (lines are shown in the legend), but it only gives me the values of the two quantitative series when I hover over a point.

I have had a look through the information at https://rstudio.github.io/dygraphs/ and can't see it anywhere there.

Is there any way I can get it to also show the qualitative values when I hover each point?

Thanks!

owaiapu
  • 11
  • 1
  • When you are doing `my_data_xts <- xts(x = my_data, order.by = my_data$date)` all the numeric values of `my_data` are transformed to character. – Ronak Shah Feb 04 '21 at 04:36
  • Thanks for you response - it still plots the values correctly, and I'm able to do calculations from them so I wasn't aware. How do I prevent this? – owaiapu Feb 04 '21 at 20:06
  • I am not sure if you can use character values with `dygraphs`. – Ronak Shah Feb 05 '21 at 07:38

0 Answers0