1

我有一个时间序列的定量和定性数据。我正在尝试使用 dyGraphs 绘制数据的时间序列,但我也希望能够在将鼠标悬停在某个点上时查看定性数据。

像这样的东西:

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)

当我运行它时,图表似乎认识到包含了定性系列(图例中显示了线条),但是当我将鼠标悬停在一个点上时,它只给了我两个定量系列的值。

我查看了https://rstudio.github.io/dygraphs/上的信息,但在那里的任何地方都看不到它。

当我悬停每个点时,有什么方法可以让它也显示定性值?

谢谢!

4

0 回答 0