SERVER: Example
ui <- fluidPage(
titlePanel("Displaying reactive output"),
sidebarLayout(
sidebarPanel(
selectInput("selection", label = h3("Select box"),
choices = list("Fertility" = "Fertility",
"Agriculture" = "Agriculture",
"Examination" = "Examination",
"Education" = "Education",
"Catholic" = "Catholic",
"Infant.Mortality" = "Infant.Mortality"),
selected = 1) # Selection is a variablename!
),
mainPanel( # Draw main panel
plotOutput("distPlot") # Put the output - a plot - into the main panel
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- swiss[, input$selection] # USING WIDGET VALUE
hist(x, col = 'darkgray', border = 'white',
xlab=input$selection,
main="Swiss French Provinces Fertility and Socioeconomic Indicators (1888) Data")
})
}
shinyApp(ui=ui, server = server)