FreddyHernandez commited on
Commit
3acd77a
1 Parent(s): a6b0596

Upload 2 files

Browse files
Files changed (2) hide show
  1. server.R +11 -0
  2. ui.R +39 -0
server.R ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ shinyServer(function(input, output) {
4
+
5
+ output$grafico1 <- renderPlot({
6
+ prob <- dbinom(x=0:input$n, size=input$n, prob=input$p)
7
+ barplot(prob, ylim=c(0, 1), names.arg=0:input$n,
8
+ xlab="x", ylab=expression(P(X==x)), col="deepskyblue3", las=1)
9
+ grid()
10
+ })
11
+ })
ui.R ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ shinyUI(fluidPage(
4
+
5
+ # Application title
6
+ titlePanel("Distribución binomial"),
7
+
8
+ sidebarLayout(
9
+ sidebarPanel(
10
+ p("Modifique los valores de los parámetros y observe lo
11
+ que sucede en el diagrama"),
12
+ br(),
13
+ sliderInput(inputId = "p",
14
+ label = "Probabilidad de éxito p:",
15
+ min = 0,
16
+ max = 1,
17
+ value = 0.4,
18
+ step= 0.1,
19
+ animate = TRUE),
20
+ sliderInput(inputId = "n",
21
+ label = "Número de ensayos n:",
22
+ min = 1,
23
+ max = 30,
24
+ value = 9,
25
+ step = 1,
26
+ animate = TRUE),
27
+ br(),
28
+ p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
29
+ tags$a(href="https://srunal.github.io/",
30
+ "https://srunal.github.io/")
31
+ ),
32
+
33
+ # Show a plot of the generated distribution
34
+ mainPanel(
35
+ h3("Diagrama de barras para las probabilidades", align = "center"),
36
+ plotOutput("grafico1")
37
+ )
38
+ )
39
+ ))