Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Last active May 22, 2016 19:18
Show Gist options
  • Save aagarw30/5ef9b71788d0e285c07f9bef826d230c to your computer and use it in GitHub Desktop.
Save aagarw30/5ef9b71788d0e285c07f9bef826d230c to your computer and use it in GitHub Desktop.
SelectInput with options and actions
Title: Demo for multiple options and actions using selectinput
Description: Powered by R, Shiny and Rstudio.
License: GPL-3
Author: Abhinav Agrawal
DisplayMode: Showcase
Tags: R, R Shiny, shinydashboard
Type: Shiny
library(shiny)
shinyServer(function(input, output){
output$a <- renderUI({
if(input$Select=="a - slider")
sliderInput("slider", "slider", min = 1, max = 10, value = 5)
else
return()}
)
output$b <- renderPlot({
if(input$Select=="b - histogram")
hist(mtcars$mpg)
else
return()
})
output$c <- renderText({
if(input$Select=="c - mean")
paste("mean mpg=", mean(mtcars$mpg))
else
return()
})
})
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(selectInput("Select", "Select", choices = c("a - slider", "b - histogram", "c - mean"), selected = "a")),
mainPanel(
uiOutput("a"),
plotOutput("b"),
textOutput("c")
)
))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment