我一直在使用dygraphs库将一些非常漂亮的时间序列图放在闪亮的应用程序中。我特别喜欢将group
参数与dygraph
结合使用dyRangeSelector
来跨越多个dygraphs同步缩放级别。从闪亮的应用程序中提取dygraph中的dyRangeSelector值
有没有办法使其他闪亮的输出反应对用户操纵范围选择器?借此示例应用程序,它显示了一个简单dygraph和求和系列于下表:
# app.R
library(shiny)
library(dygraphs)
library(dplyr)
indoConc <- Indometh[Indometh$Subject == 1, c("time", "conc")]
ui <- fluidPage(
dygraphOutput("plot"),
tableOutput("table")
)
server <- shinyServer(function(input, output) {
output$plot <- renderDygraph({
indoConc %>%
dygraph %>%
dyRangeSelector
})
output$table <- renderTable({
indoConc %>%
filter(time >= min(indoConc$time), time <= max(indoConc$time)) %>%
summarise(total_conc = sum(conc))
})
})
shinyApp(ui, server)
我想该表为只通过用户当前选择的时间间隔之和。这意味着更改filter
行以使用除最小/最大点之外的其他值(这不会导致过滤)。
如何从相应格式的范围选择器中提取这两个值,以便我可以在filter
调用中使用它们,并在用户移动滑块时反应性地更新表格?
我可以看到那里有像一些隐藏的输入'plot_date_window'我可以使用,这要归功于这个答案:http://stackoverflow.com/questions/30955578/r-shiny-dygraphs - 系列反应的最新窗口。现在的诀窍是从中提取我的非时间序列y值;可能吗? – ClaytonJY