每个Select Box小部件输出的不同数据源

时间:2015-08-25 19:13:10

标签: shiny

我的选择框小部件中有3个数据源。当我从应用程序的选择框中选择不同的数据源时,我正在尝试更新图形。但是,当我更改数据源时,图表不会更新。我是否需要使用reactive命令?

shinyUI(fluidPage(

  # Application title
  titlePanel("Temperature Data"),
  sidebarLayout(
    sidebarPanel(
      selectInput("dataSelection", label = "Choose a Data Set", choices = c("Dataset 1", "Dataset 2")),
      selectInput("component1", label = "Choose a Chart",
                  choices = c("Watts"),
                  selected = "Watts" )),

    mainPanel(
      dygraphOutput("TempRise")

    )
    )




#server.r
    shinyServer(function(input, output) {

      output$TempRise <- renderDygraph({

        dataSource <- switch(input$dataSelection,
                     "Dataset 1" = Data1,
                     "Dataset 2" = Data2)

        TempData <- switch(input$component1,
                       "Watts" = dataSource$Watts)
    dygraph(TempData, main = "Temperature Data") %>%
          dyRangeSelector()

    })
    })

0 个答案:

没有答案