Spaces:
Runtime error
Runtime error
FreddyHernandez
commited on
Commit
•
09b933e
1
Parent(s):
50e4b2d
Upload 2 files
Browse files
server.R
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyServer(function(input, output)
|
4 |
+
{
|
5 |
+
|
6 |
+
output$grafico1 <- renderPlot({
|
7 |
+
prob <- dnbinom(x=0:input$x.max, size=input$exitos, prob=input$p, log=F)
|
8 |
+
barplot(prob, ylim=c(0, 1), names.arg=0:input$x.max,
|
9 |
+
xlab=paste("X: número de fracasos hasta conseguir ", input$exitos, "exitos"),
|
10 |
+
ylab=expression(P(X==x)), col="deepskyblue3", las=1)
|
11 |
+
grid()
|
12 |
+
})
|
13 |
+
output$github <- renderText({
|
14 |
+
if (input$p %in% 0:1) paste("No tiene sentido ese valor de p")
|
15 |
+
})
|
16 |
+
})
|
17 |
+
|
ui.R
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
library(shiny)
|
3 |
+
|
4 |
+
# Define UI for application that draws a histogram
|
5 |
+
shinyUI(fluidPage(
|
6 |
+
|
7 |
+
# Application title
|
8 |
+
titlePanel("Distribución Binomial Negativa - Versión 1"),
|
9 |
+
|
10 |
+
# Sidebar with a slider input for the number of bins
|
11 |
+
sidebarLayout(
|
12 |
+
sidebarPanel(
|
13 |
+
p("En esta parametrización el parámetro p representa
|
14 |
+
la probabilidad de éxito individual y k representa
|
15 |
+
el número de éxitos."),
|
16 |
+
br(),
|
17 |
+
p("Modifique los valores de los parámetros y
|
18 |
+
observe lo que sucede en el diagrama"),
|
19 |
+
br(),
|
20 |
+
sliderInput(inputId = "p",
|
21 |
+
label = "Probabilidad individual de éxito p:",
|
22 |
+
min = 0,
|
23 |
+
max = 1,
|
24 |
+
value = 0.6,
|
25 |
+
step= 0.1,
|
26 |
+
animate = TRUE),
|
27 |
+
sliderInput(inputId = "exitos",
|
28 |
+
label = "Número de éxitos k:",
|
29 |
+
min = 1,
|
30 |
+
max = 30,
|
31 |
+
value = 5,
|
32 |
+
step = 1,
|
33 |
+
animate = TRUE),
|
34 |
+
sliderInput(inputId = "x.max",
|
35 |
+
label = "Ingrese el máximo valor de x para el cual desea
|
36 |
+
ver las probabilidades:",
|
37 |
+
min = 1,
|
38 |
+
max = 70,
|
39 |
+
value = 15,
|
40 |
+
step = 1),
|
41 |
+
br(),
|
42 |
+
p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
|
43 |
+
tags$a(href="https://srunal.github.io",
|
44 |
+
"https://srunal.github.io")
|
45 |
+
),
|
46 |
+
|
47 |
+
# Show a plot of the generated distribution
|
48 |
+
mainPanel(
|
49 |
+
h3("Diagrama de barras para las probabilidades", align = "center"),
|
50 |
+
plotOutput("grafico1"),
|
51 |
+
verbatimTextOutput('github')
|
52 |
+
)
|
53 |
+
)
|
54 |
+
))
|