I defined a selectInput as below. I want to access the label of each choice, and render it on the main panel.
If the user selects "Sugar sweetened bev.", I want to render on the main panel something like this:
"You chose Sugar sweetened bev.", but instead I get "You chose ssb".
The reason I setup my selectInput choices this way is because I want the left-hand side for the title of the graph, and the right-side is the variable name.
Any advice or alternative direction is much appreciated!
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("foodvars", "Select food:",
choices = c("Beef/Pork" = "beefpork",
"Sugar sweeteened bev." = "ssb",
"Total fruit" = "total_fruit"))),
mainPanel(
textOutput("dispText")))
)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("foodvars", "Select food:",
choices = c("Beef/Pork" = "beefpork",
"Sugar sweeteened bev." = "ssb",
"Total fruit" = "total_fruit"))),
mainPanel(
textOutput("dispText")))
)
server <- function(input, output) {
output$dispText <- renderText({
paste("You chose ",input$foodvars)})
}
shinyApp(ui = ui, server = server)