闪亮 - 通过 updateSelectInput() 更改 selectInput() 中的“选择”

时间:2021-04-17 02:10:13

标签: r shiny

我正在尝试根据第一个 selectInput() 中的选择更改第二个 selectInput() 中的选择。这是我的代表。在此先感谢您的帮助。

    library(shiny)
    ui <- fluidPage(
      tabPanel("tbls",
        selectInput("tab1",label="Pick a table:",choices=c("a","b","c")),
        selectInput("cht1",label="Pick a time series:",choices=c("d","e","f"))
      )
    )
    server <- function(input,output,session) {
      Nchoices <- reactive({case_when(
        input$tab1=="a" ~c("d","e","f"),
        input$tab1=="b" ~c("g","h","i"),
        input$tab1=="c" ~c("j","k","l")
      )}) 
      observeEvent(input$tab1,{updateSelectInput(session,input$cht1,
        label="Pick a time series:",choices=Nchoices(),selected=NULL)})
      observe(print(Nchoices()))
    }
    shinyApp(ui, server)

0 个答案:

没有答案
相关问题