I have an app which is meant to render a table of one of two possible datasets: either mtcars, which comes with base R's datasets package, or BostonHousing which comes with the mlbench package. For some reason I can't get this to run properly. Can anyone suggest a fix?
library(shiny)
library(mlbench)
ui <- fluidPage(
selectInput("select", "Select",
choices = c("mtcars", "BostonHousing"),
selected = "mtcars"),
tableOutput("table")
)
server <- function(input, output, session) {
dat <- reactive(data(input$select))
output$table <- renderTable({
dat()
})
}
shinyApp(ui, server)
Edit: for clarification, the data frame must be stored in dat. The renderTable component is there only to confirm that it loaded successfully.