You can use selectInput to select the entries from the list and updateSelectInput to update the selections based on the selection made a level up.
library(shiny)
library(tidyverse)
ui <- fluidPage(
titlePanel("Multiple selection demo"),
# Sidebar
sidebarLayout(
sidebarPanel(
selectInput("manufacturer", "select a manufacturer", choices = unique(mpg$manufacturer)),
selectInput("model", "select a model",
choices = NULL, selected = NULL),
selectInput("trans", "select a transmission",
choices = NULL, selected = NULL)
),
# MainPanel
mainPanel(
tableOutput("results_table"))
))
# server
server <- function(input, output, session) {
observeEvent(input$manufacturer, {
updateSelectInput(session = session, inputId = "model",
choices = unique(filter(mpg, manufacturer == input$manufacturer)$model),
selected = "")
})
observeEvent(c(input$model, input$manufacturer), {
updateSelectInput(session = session, inputId = "trans",
choices = unique(filter(mpg, model == input$model)$trans),
selected = "")
})
#calculate the results
results = reactive({
req(input$manufacturer)
req(input$model)
req(input$trans)
filter(mpg, manufacturer == input$manufacturer &
model == input$model &
trans == input$trans)
})
#show the results as an table
output$results_table = renderTable({
req(results())
results()
})
}
# Run the application
shinyApp(ui = ui, server = server)