How can I solve table problem in r shiny

ui <- fluidPage(
  titlePanel("Select the location and date of the observatory"),
  
  sidebarPanel(
    selectInput("loc", "Select the location",
                c("chc" = "101", "sdg" = "108")
    ),
                
    conditionalPanel(
      condition = "input.loc == '101'",
      selectInput(
        "branch1","select branch:",
        c("aa","bb","cc")
      )),
                
    conditionalPanel(condition = "input.loc == '108'",
        selectInput("branch2","select branch:",
        c("dd","ee","ff"))
      ),
    dateRangeInput("date","select date:", start = "2020-01-01",end = "2021-05-29")
  ),

  mainPanel(
    dataTableOutput('table')
  )
)

server <- function(input, output) {
  
  output$table <- renderDataTable(
    if(input$branch1 == "aa"){
      subset(temp,stnld == "93")[,c(2,3,4,5)]}
    
    else if(input$branch1 == "bb"){
      subset(temp,stnld == "101")[,c(2,3,4,5)]}
    
    else if(input$branch1 == "cc"){
      subset(temp,stnld == "212")[,c(2,3,4,5)]}
    
    else if(input$branch2 == "dd"){
      subset(temp,stnld == "98")[,c(2,3,4,5)]}
    
    else if(input$branch2 == "ee"){
      subset(temp,stnld == "99")[,c(2,3,4,5)]}
    
    else if(input$branch2 == "ff"){
      subset(temp,stnld == "108")[,c(2,3,4,5)]}
    
   ,options = list(pageLength = 5))
}




shinyApp(ui, server)

Tables in aa,bb,cc in branch1 work, so why don't the tables in dd,ee,ff in branch2 change?

Thanks for your help

Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

temp has not been provided, but is key to your app

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Reprex Guide

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.