How to read and show data sequentially in R shiny?

Hi all,

I want to read data from an excel. Data is like this-

image .

I want to write a program which flows sequentially. Like in the example-

  1. If I select India, it should show the cities.
  2. If I select New Delhi as city it should show the subsequent popular item
  3. If I select popular item, it should show the subsequent rating.

How can I do this?

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)

Hi Matthias,

It works.

But what if incase of selectInput, you have action buttons?