Selecting inputs that is filtered based on previous selectInput values

I'm working on a project where table is filtered based on the Inputs provided by the user. There are three selectInput conditions. For better understanding lets assume the mtcars data. User can first select the number of cylinders, then the user should see a selectInput list of number of gears filtered for given value of cylinder. (**for instance, if number of cylinder is 4, then number of gears should be either 4,3,5 **)
Similarly, after selecting the Number of Cylinders and Number of gears the user must see the value of Transmission type as either 0,1.
The table should be updated and filtered based on the selected inputs.
I have tried the given code. Please help me.

#loading libraries

#using mtcars as dataset
df <- read.csv("")

# Define UI for application
ui <- fluidPage(
  # Application title
  titlePanel("Details of Given Cars"),
  # Sidebar for input  filter
      selectInput("cylinder","Number of Cylinders",unique(df$cyl)),
      selectizeInput("gears","Number of gears",choices = NULL),
      selectizeInput("gearbox","Transmission Type 'AUTO=0'",choices = NULL)
    # Show a table

# Define server logic required
server <- function(input, output,session) {
  #----reactive calculations
  cyl_sel <- reactive({
    df %>% filter(cyl == input$cylinder)
    updateSelectizeInput(session,"gears", choices = cyl_sel()$gear)
  # })
  gearbox_sel <- reactive({
    cyl_sel() %>% filter(am == input$gears)
    updateSelectizeInput(session,"gearbox",choices = gearbox_sel()$am)
  output$table <- DT::renderDT({
    df %>% filter(cyl == input$cylinder,
                  gear == input$gears)
                 #> am== input$gearbox) #> commented because output is not shown when uncommented

#> Run the application 
shinyApp(ui = ui, server = server)

Crossposted on Stack Overflow

you mismatched the gears filter to am rather than gear
you missed brackets at the end of observeEvent(gearbox_sel

    gearbox_sel <- reactive({
      cyl_sel() %>% filter(gear == input$gears)
      updateSelectizeInput(session,"gearbox",choices = gearbox_sel()$am)
      output$table <- DT::renderDT({
        df %>% filter(cyl == input$cylinder,
                      gear == input$gears,
                      am== input$gearbox)

Thank you so much for your help.
I just realized that.

This topic was automatically closed 7 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.