Spaces:
Sleeping
Sleeping
FreddyHernandez
commited on
Commit
•
6e9c5c5
1
Parent(s):
54ed0de
Nuevos
Browse files
server.R
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This is the server logic for a Shiny web application.
|
2 |
+
# You can find out more about building applications with Shiny here:
|
3 |
+
# http://shiny.rstudio.com
|
4 |
+
library(shiny)
|
5 |
+
if (!require('gamlss')) install.packages("gamlss")
|
6 |
+
library(gamlss)
|
7 |
+
shinyServer(function(input, output) {
|
8 |
+
output$distPlot <- renderPlot({
|
9 |
+
# generate values of the ZIP distribution based on input$mu from ui.R
|
10 |
+
x <- seq(0, input$xmax, 1)
|
11 |
+
y <- dZIP(x, mu=input$mu, sigma=input$Prop)
|
12 |
+
# draw the histogram with the specified number of bins
|
13 |
+
barplot(y, main='Diagrama de barras para las probabilidades',
|
14 |
+
xlab='x', ylab=expression(P(X==x)), las=1, col='deepskyblue3',
|
15 |
+
names.arg = x, ylim=c(0, 1))
|
16 |
+
grid()
|
17 |
+
})
|
18 |
+
})
|
ui.R
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
shinyUI(fluidPage(
|
3 |
+
# Application title
|
4 |
+
titlePanel("Distribución Zero Inflated Poisson (ZIP)"),
|
5 |
+
|
6 |
+
sidebarLayout(
|
7 |
+
sidebarPanel(
|
8 |
+
HTML("En la distribución ZIP el parámetro λ representa
|
9 |
+
la media de la distribución Poisson y
|
10 |
+
Prop representa el porcentaje de exceso de ceros."),
|
11 |
+
br(),
|
12 |
+
p("Modifique los valores de los parámetros y
|
13 |
+
observe lo que sucede en el gráfico."),
|
14 |
+
br(),
|
15 |
+
sliderInput("mu", HTML("Media de la Poisson, λ:"),
|
16 |
+
min = 0,
|
17 |
+
max = 15,
|
18 |
+
step= 0.5,
|
19 |
+
value = 5,
|
20 |
+
animate = TRUE),
|
21 |
+
sliderInput("Prop",
|
22 |
+
"Porcentaje de la distribución concentrada en cero:",
|
23 |
+
min = 0.0001,
|
24 |
+
max = .9999,
|
25 |
+
step=0.05,
|
26 |
+
value = 0.5,
|
27 |
+
animate =TRUE),
|
28 |
+
numericInput("xmax",
|
29 |
+
"Ingrese el máximo valor de x para el cual desea ver las probabilidades:",
|
30 |
+
min = 5,
|
31 |
+
max = 50,
|
32 |
+
step= 1,
|
33 |
+
value = 15),
|
34 |
+
br(),
|
35 |
+
p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
|
36 |
+
tags$a(href="https://srunal.github.io/", "https://srunal.github.io/")
|
37 |
+
),
|
38 |
+
# Show a plot of the generated distribution
|
39 |
+
mainPanel(
|
40 |
+
plotOutput("distPlot")
|
41 |
+
)
|
42 |
+
)
|
43 |
+
))
|