This seems like it should be trivial but I'm obviously missing something. I'd like to have the selection from a selectInput() be used to create a data frame. The selectInput() produces a character output that doesn't seem to work as an input for creating a data frame. My ui.R and server.R code is below. The df<-data.frame(input$select, header=TRUE) line doesn't produce the expected output. Thanks in advance for your assistance.
ui.R
library(shiny)
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
titlePanel("Select Test Dataset"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
selectInput("select", "Test Dataset",
choices= list("Model Year 2011" = 'cars2011', "Model Year 2012" = 'cars2012'),selected='cars2011')
),
# mainPanel Output
mainPanel(
verbatimTextOutput("value"),
verbatimTextOutput("type"),
dataTableOutput(outputId="data")
)
)
)
)
server.R
library(AppliedPredictiveModeling)
data(FuelEconomy)
shinyServer(function(input, output) {
output$value <- renderPrint({ input$select })
output$type <- renderPrint({class(input$select)})
output$data <- reactive({
df <- data.frame(input$select, header=TRUE)
head(df)
})
})