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.


ui <- fluidPage(

    titlePanel("Multiple selection demo"),

    # Sidebar  
            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 

# 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({

      filter(mpg, manufacturer == input$manufacturer & 
                    model == input$model &
                     trans == input$trans)    

#show the results as an table
output$results_table = renderTable({

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

Hi Matthias,

It works.

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

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