Guest User

Untitled

a guest
Jun 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. library(shiny)
  2.  
  3. ui <- fluidPage(
  4.  
  5. titlePanel("Géiser Faithful"),
  6.  
  7. sidebarLayout(
  8.  
  9. sidebarPanel(
  10.  
  11. sliderInput(inputId = "dots",
  12. label = "Rango de puntos:",
  13. min = 1,
  14. max = dim(faithful)[1],
  15. value = c(1,dim(faithful)[1])),
  16.  
  17. hr(),
  18.  
  19. sliderInput(inputId = "bins",
  20. label = "Número de Contenedores:",
  21. min = 1,
  22. max = 50,
  23. value = 30)
  24.  
  25. ),
  26.  
  27. mainPanel(
  28.  
  29. fluidRow(
  30.  
  31. column(6,
  32.  
  33. plotOutput(outputId = "scatter")
  34.  
  35. ),
  36.  
  37. column(6,
  38.  
  39. plotOutput(outputId = "distPlot")
  40.  
  41. )
  42.  
  43. ),
  44.  
  45. fluidRow(
  46.  
  47. column(4,
  48.  
  49. h4("Total observaciones"),
  50. textOutput("obs")
  51.  
  52. ),
  53.  
  54. column(4,
  55.  
  56. h4("Máximo Tiempo Erupción"),
  57. textOutput("erupcion")
  58.  
  59. ),
  60.  
  61. column(4,
  62.  
  63. h4("Máximo Tiempo Espera"),
  64. textOutput("espera")
  65.  
  66. )
  67. )
  68.  
  69. )
  70. )
  71. )
  72.  
  73. server <- function(input, output) {
  74.  
  75. output$distPlot <- renderPlot({
  76.  
  77. x <- faithful$waiting
  78. bins <- seq(min(x), max(x), length.out = input$bins + 1)
  79.  
  80. hist(x, breaks = bins, col = "#75AADB", border = "white",
  81. xlab = "Tiempo de espera hasta la próxima erupción (en mins)",
  82. main = "Histograma de tiempos de esperas")
  83.  
  84. })
  85.  
  86. output$scatter <- renderPlot({
  87.  
  88. x <- faithful[c(seq(input$dots[1], input$dots[2])),]
  89.  
  90. plot(x$eruptions, x$waiting, col = "orange",
  91. main = "Erupciones frente a Tiempos de Espera",
  92. xlab = "Tiempo de erupción",
  93. ylab = "Tiempo de espera"
  94. )
  95.  
  96. })
  97.  
  98. output$obs <- renderText(dim(faithful)[1])
  99.  
  100. output$erupcion <- renderText(max(faithful$eruptions))
  101.  
  102. output$espera <- renderText(max(faithful$waiting))
  103.  
  104. }
  105.  
  106. shinyApp(ui = ui, server = server)
Add Comment
Please, Sign In to add comment