Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. library(shiny)
  2. library(dplyr)
  3. library(ggplot2)
  4.  
  5. all <- read.csv("/home/trentdennis/ALLMLBgameswopp.csv", stringsAsFactors = FALSE)
  6.  
  7.  
  8. function(input,output) {
  9. output$teamOutput <- renderUI({
  10. selectInput("teamInput", "Team",
  11. sort(unique(all$Abbreviation2)),
  12. selected = "ARI")
  13. })
  14.  
  15. filtered <- reactive({
  16. if(is.null(input$teamInput)) {
  17. return(NULL)
  18. }
  19.  
  20.  
  21. all %>%
  22. filter(ML >= input$percentInput[1],
  23. ML <= input$percentInput[2],
  24. SP >= input$percenttInput[1],
  25. SP <= input$percenttInput[2],
  26. SPResult == input$statusInput,
  27. Location == input$locInput,
  28. Abbreviation2 == input$teamInput
  29. )
  30.  
  31.  
  32. })
  33. output$ggplot <- renderPlot({
  34. if(is.null(filtered())) {
  35. return()
  36. }
  37.  
  38. ggplot(filtered()) +
  39. geom_point(aes(x = ML, y = Result, color = Location, alpha = .4)) +
  40. theme_classic()
  41.  
  42. })
  43.  
  44. output$ggplot2 <- renderPlot({
  45. if(is.null(filtered())) {
  46. return()
  47. }
  48.  
  49. ggplot(filtered()) +
  50. geom_histogram(aes(x = Result)) +
  51. theme_classic()
  52.  
  53. })
  54.  
  55.  
  56. output$results <- renderTable({
  57. filtered()
  58. })
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement