Spaces:
Runtime error
Runtime error
FreddyHernandez
commited on
Commit
•
2a2cd26
1
Parent(s):
7677ccb
Upload 2 files
Browse files
server.R
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyServer(function(input, output)
|
4 |
+
{
|
5 |
+
|
6 |
+
output$grafico1 <- renderPlot({
|
7 |
+
prob <- dnbinom(x=0:input$x.max,
|
8 |
+
size=input$k,
|
9 |
+
mu=input$mu, log=F)
|
10 |
+
barplot(prob, ylim=c(0, 1), names.arg=0:input$x.max,
|
11 |
+
xlab=paste("X"),
|
12 |
+
ylab=expression(P(X==x)), col="deepskyblue3", las=1)
|
13 |
+
grid()
|
14 |
+
})
|
15 |
+
output$github <- renderText({
|
16 |
+
if (input$mu %in% 0:1) paste("No tiene sentido mu = 0.")
|
17 |
+
})
|
18 |
+
})
|
19 |
+
|
ui.R
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 2"),
|
9 |
+
|
10 |
+
# Sidebar with a slider input for the number of bins
|
11 |
+
sidebarLayout(
|
12 |
+
sidebarPanel(
|
13 |
+
HTML("En esta parametrización de la Binomial Negativa
|
14 |
+
el parámetro μ representa la media y
|
15 |
+
k representa el parámetro de precisión"),
|
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 = "mu",
|
21 |
+
label = HTML("Media μ:"),
|
22 |
+
min = 0,
|
23 |
+
max = 50,
|
24 |
+
value = 2.5,
|
25 |
+
step= 0.1,
|
26 |
+
animate = TRUE),
|
27 |
+
sliderInput(inputId = "k",
|
28 |
+
label = "Valor de k:",
|
29 |
+
min = 1,
|
30 |
+
max = 100,
|
31 |
+
value = 5,
|
32 |
+
step = 0.5,
|
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 = 50,
|
39 |
+
value = 30,
|
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", "https://srunal.github.io")
|
44 |
+
),
|
45 |
+
|
46 |
+
# Show a plot of the generated distribution
|
47 |
+
mainPanel(
|
48 |
+
h3("Diagrama de barras para las probabilidades", align = "center"),
|
49 |
+
plotOutput("grafico1"),
|
50 |
+
verbatimTextOutput('github')
|
51 |
+
)
|
52 |
+
)
|
53 |
+
))
|