Last active
May 22, 2016 19:18
-
-
Save aagarw30/5ef9b71788d0e285c07f9bef826d230c to your computer and use it in GitHub Desktop.
SelectInput with options and actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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