File size: 701 Bytes
40d6528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
shinyServer(function(input, output) {
  
  output$grafico1 <- renderPlot({
    if (input$min > input$max) {
      plot(c(-5, 5), c(0, 1), xlab="", ylab="", type='n',
           xaxt='n', yaxt='n', bty='n')
      text(x=0, y=0.5, col='red', cex=2,
           label='Revise los valores que ingresó.')
      text(x=0, y=0.4, col='purple', cex=2,
           label='El mínimo no puede ser mayor que el máximo.')
    }
    else {
      n <- input$max - input$min + 1
      x <- seq(from=input$min, to=input$max)
      prob <- rep(1/n, n)
      barplot(prob, ylim=c(0, 1), names.arg=x,
              xlab="x", ylab=expression(P(X==x)), 
              col="deepskyblue3", las=1)
      grid()
    }
  })
})