Advertisement
Guest User

Server

a guest
Dec 3rd, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.29 KB | None | 0 0
  1. library(shiny)
  2. library(shinydashboard)
  3. library(ggplot2)
  4. library(rsconnect)
  5.  
  6.  
  7. shinyServer(function(input, output){
  8.  
  9.   datasetInput <- reactive({
  10.     switch(input$year,
  11.            "2017" = m17,
  12.            "2018" = m18)
  13.   }
  14.   )
  15.  
  16.   stInput <- reactive({
  17.     dset <- datasetInput()
  18.     switch(input$st,
  19.            "Elementary" = dset[which(dset$schtype == "ES"),],
  20.            "Middle" = dset[which(dset$schtype == "MS"),],
  21.            "High" = dset[which(dset$schtype == "HS"),])
  22.   })
  23.  
  24.  
  25.  
  26.   output$data <- renderTable({
  27.     cc <- as.numeric(input$var)
  28.     ccc <- as.numeric(input$gen)
  29.     st <- stInput()
  30.     st[1:20,c(cc,ccc)]
  31.   })
  32.  
  33.   output$summary <- renderTable({
  34.     st <- datasetInput()
  35.     summary(st)
  36.   })
  37.  
  38.  
  39.   output$mybar<- renderPlot({
  40.     coco <- as.numeric(input$var)
  41.     coc <- as.numeric(input$gen)
  42.     st <- stInput()
  43.     ggplot(st, aes(y=st[,coco], x = st[,coc], fill = highneeds)) +
  44.       stat_summary(fun.y = mean, geom = "bar", position = "dodge")+
  45.       labs(y = "score", x = names(st[coc]))
  46.    
  47.   })
  48.  
  49.   output$mybar1<- renderPlot({
  50.     coco <- as.numeric(input$var)
  51.     st <- stInput()
  52.     ggplot(st, aes(x=st[,coco])) +
  53.       geom_histogram(color="black", fill="lightblue", linetype = "dashed")+
  54.       labs(x = "score")
  55.    
  56.   })
  57. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement