Reactive select input to update table

shiny
shinydashboard

#1

I am trying to understand the reactive part in R shiny. In that process I am trying to update an output table based on the input change while selecting values from the age drop down. It seems to do it by the first value but when I change any value from the age drop down it wont update my table . The input I am using is
chooseage. Below is the code which I am using.

library(shiny)
library(shinydashboard)
library(shinyBS)
library(knitr)
library(kableExtra)
library(shiny)
library(shinythemes)


ui <- dashboardPage(
  dashboardHeader(disable = F, title = "Study"),
  dashboardSidebar(sidebarMenu(
    menuItem(
      "Population Filter",
      uiOutput("choose_age")
    )
  )),
  dashboardBody(box(
    width = 12,
    tabBox(
      width = 12,
      id = "tabBox_next_previous",
      tabPanel("Initiation",
               fluidRow(
                 box(
                   width = 5,
                   solidHeader = TRUE,
                   status = "primary",
                   tableOutput("smoke"),
                   collapsible = F
                 )
               ))
      
    ),
       uiOutput("Next_Previous")
  ))
)
server <- function(input, output, session) {
    # Drop-down selection box for which Age bracket to be selected
    output$choose_age <- renderUI({
      selectInput("selected_age", "Age", as.list(levels(with_demo_vars$age)))
    })
      myData <- reactive({
      with_demo_vars %>%
        filter(age == input$choose_age) %>%
        pct_ever_user(type = "SM")
    })
       output$smoke <-
      renderTable({
        head(myData())
      })
        
      }
shinyApp(ui = ui, server = server)


#2

You're using input$choose_age, but choose_age isn't the name of your selectInput; it's the name of your uiOutput, that happens to contain your selectInput. The name of your actual selectInput is selected_age (so, input$selected_age).

I'd also strongly encourage you to clean up your indentation! It will help greatly the next time you forget a closing brace or whatever. You can easily do this in RStudio by doing Ctrl+a (select all), Ctrl+i (auto-indent).