The following code allows the user to select between 2 datasets in a dropdown and displays all of the columns for the selected dataset. I would like to add a second dropdown that is dynamically cast with the names of the columns in the selected first dropdown so that the user can select to display a single column only. The goal is to be able to add any dataset to the first dropdown and have it's columns listed in the second dropdown.
library(shiny)ui <- shinyUI( fluidPage( selectInput("dataset", label = NULL, choices = c("mtcars", "rock")), tableOutput("contents") ))server <- function(input, output, session) { myData <- reactive({ switch(input$dataset,"rock" = rock,"mtcars" = mtcars) }) output$contents <- renderTable({ myData() }) observe({ updateSelectInput(session, "myNames", label = "myNames", choices = myData()$names, selected = myData()$names[1]) })}shinyApp(ui, server)