Question: I am trying to create a shiny app with multiple tabs. Each tab is to have its own sidebar. I haven't been able to get this to work. Any help on what is wrong would be appreciated.
Below is the code

```
    ui <- fluidPage(

  titlePanel("Hi"),    

  sidebarLayout(position = "left",
                sidebarPanel(
                  conditionalPanel(condition = "input.tabs1==1",
                                   selectizeInput('invar',"Reg in", choices = varnames, multiple = TRUE)),
                  conditionalPanel(condition = "input.tabs1==2",
                                   selectizeInput('outvar',"Reg out", choices = predictors, multiple = FALSE)),

                ),

                mainPanel(
                  tabsetPanel(id="tabs1",
                              tabPanel("input",value=1,plotOutput("Input"),
                              tabPanel("output",value=2,plotOutput("Output")
                              ))))
  )) 

```

Answer: 
First of all, check your code again. You made following mistakes:

* one tabPanel is nested inside the other one
* there's an extra comma at the end of the second `conditionalPanel()`, so you pass an empty element to `sidebarPanel()`

If I correct your mistakes and create a mock example, it works perfectly fine as is. So there isn't really a problem here:

```
ui <- fluidPage(

  titlePanel("Hi"),    
  sidebarLayout(position = "left",
                sidebarPanel(
                  conditionalPanel(condition = "input.tabs1==1",
                                   selectizeInput('invar',"Reg in", choices = letters[1:3], multiple = TRUE)),
                  conditionalPanel(condition = "input.tabs1==2",
                                   selectizeInput('outvar',"Reg out", choices = letters[4:6], multiple = FALSE))

                ),
                mainPanel(
                  tabsetPanel(id="tabs1",
                              tabPanel("input",value=1,plotOutput("Input")),
                              tabPanel("output",value=2,plotOutput("Output"))
                              )
                  )
  )) 

server <- function(input, output, session){
  output$Input <- renderPlot(plot(1))
  output$Output <- renderPlot(plot(2))
}

shinyApp(ui, server)

```

You could do this as well by using `renderUI`:

```
ui <- fluidPage(

  titlePanel("Hi"),    

  sidebarLayout(position = "left",
                sidebarPanel(
                  uiOutput("mysidebar")
                                  ),

                mainPanel(
                  tabsetPanel(id="tabs1",
                              tabPanel("input",value=1,plotOutput("Input")),
                              tabPanel("output",value=2,plotOutput("Output")
                                       )))
  )) 
server <- function(input, output, session){
  output$mysidebar <- renderUI({
    if(input$tabs1 == 1){
      selectizeInput('invar',"Reg in", choices = letters[1:3])
    } else if(input$tabs1 == 2){
      selectizeInput('outvar',"Reg out", choices = letters[4:6])
    }
  })
}
shinyApp(ui,server)

```
I do this in a very different but effective way.

```
shinyApp(
 shinyUI(
 fluidPage(
    uiOutput('mainpage')
) 
),
shinyServer(function(input, output, session) {
panel <- reactiveValues(side = NULL)
output$mainpage  <- renderUI({
   sidebarLayout(position = "left",
     sidebarPanel(
           uiOutput(panel$side)
     ),
     mainPanel(
              tabsetPanel(id="tabs1",
                          tabPanel("input",value=1,plotOutput("Input")),
                          tabPanel("output",value=2,plotOutput("Output"))
                          )
     )
  })
output$sideinput <- renderUI({
tagList(
    selectizeInput('invar',"Reg in", choices = varnames, multiple = TRUE))
    )
})
output$sideoutput <- renderUI({
tagList(
 selectizeInput('outvar',"Reg out", choices = predictors, multiple =FALSE)
    )
})
observeEvent(input$tabs1,{
   panel$side <- switch(input$tabs1,
                      1 = 'sideinput',
                      2 = 'sideoutput')
})

```

basically I am using observers as my conditionals and assigning the value of the desired panel to the variable name assigned to that panel position