Created
June 9, 2017 18:48
-
-
Save aagarw30/8faf060d975457f4a717f6800d155733 to your computer and use it in GitHub Desktop.
render Plot gist for you tube user query
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) # Load shiny package | |
| data(iris) # Load the iris dataset | |
| shinyServer( | |
| function(input, output) { | |
| output$text1 <- renderText({ | |
| colm = as.numeric(input$var) | |
| paste("Data set variable/column name is", names(iris[colm])) | |
| }) | |
| output$text2 <- renderText({ | |
| paste("Color of histogram is", input$radio) | |
| }) | |
| output$text3 <- renderText({ | |
| paste("Number of histogram BINs is", input$bin) | |
| }) | |
| output$myhist <- renderPlot( | |
| { | |
| colm = as.numeric(input$var) | |
| hist(iris[,colm], col =input$colour, xlim = c(0, max(iris[,colm])), main = "Histogram of Iris dataset", breaks = seq(0, max(iris[,colm]),l=input$bin+1), xlab = names(iris[colm]))} | |
| ) | |
| } | |
| ) | |
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
| # Install the shiny package if not already installed | |
| # install.packages("shiny") | |
| library(shiny) # load the shiny package | |
| # Define UI for application | |
| shinyUI(fluidPage( | |
| # Header or title Panel | |
| titlePanel(h4('Demostration of the renderPlot() - A Histogram with iris dataset', align = "center")), | |
| # Sidebar panel | |
| sidebarPanel( | |
| selectInput("var", label = "1. Select the quantitative Variable", | |
| choices = c("Sepal.Length" = 1, "Sepal.Width" = 2, "Petal.Length" = 3, "Petal.Width"=4), | |
| selected = 3), | |
| sliderInput("bin", "2. Select the number of histogram BINs by using the slider below", min=5, max=25, value=15), | |
| radioButtons("colour", label = "3. Select the color of histogram", | |
| choices = c("Green", "Red", | |
| "Yellow"), selected = "Green") | |
| ), | |
| # Main Panel | |
| mainPanel( | |
| textOutput("text1"), | |
| textOutput("text2"), | |
| textOutput("text3"), | |
| plotOutput("myhist") | |
| ) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment