Spaces:
Sleeping
Sleeping
FreddyHernandez
commited on
Commit
路
9cd4d47
1
Parent(s):
62a5b47
Upload 2 files
Browse files
server.R
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("actuar")) install.packages("actuar")
|
6 |
+
library(actuar)
|
7 |
+
|
8 |
+
shinyServer(function(input, output) {
|
9 |
+
output$distPlot <- renderPlot({
|
10 |
+
# generate values of the ZIP distribution based on input$mu from ui.R
|
11 |
+
x <- seq(1, input$xmax, 1)
|
12 |
+
y <- dztpois(x, lambda=input$lambda)
|
13 |
+
# draw the histogram with the specified number of bins
|
14 |
+
barplot(y, main='Diagrama de barras para las probabilidades',
|
15 |
+
xlab='x', ylab=expression(P(X==x)), las=1, col='deepskyblue3',
|
16 |
+
names.arg = x, ylim=c(0, 1))
|
17 |
+
grid()
|
18 |
+
})
|
19 |
+
})
|
ui.R
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyUI(fluidPage(
|
4 |
+
# Application title
|
5 |
+
titlePanel("Distribuci贸n Zero Truncated Poisson (ZTP)"),
|
6 |
+
|
7 |
+
sidebarLayout(
|
8 |
+
sidebarPanel(
|
9 |
+
HTML("En la distribuci贸n ZTP el par谩metro λ representa
|
10 |
+
la media de la distribuci贸n Poisson, en esta distribuci贸n
|
11 |
+
no hay ceros, est谩 truncada en cero e inicia en 1."),
|
12 |
+
br(),
|
13 |
+
p("Modifique los valores de los par谩metros y
|
14 |
+
observe lo que sucede en el gr谩fico."),
|
15 |
+
br(),
|
16 |
+
sliderInput("lambda", HTML("Media de la Poisson, λ:"),
|
17 |
+
min = 0,
|
18 |
+
max = 15,
|
19 |
+
step= 0.5,
|
20 |
+
value = 5,
|
21 |
+
animate = TRUE),
|
22 |
+
numericInput("xmax",
|
23 |
+
"Ingrese el m谩ximo valor de x para el cual desea ver las probabilidades:",
|
24 |
+
min = 5,
|
25 |
+
max = 50,
|
26 |
+
step= 1,
|
27 |
+
value = 15),
|
28 |
+
br(),
|
29 |
+
p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
|
30 |
+
tags$a(href="https://srunal.github.io/", "https://srunal.github.io/")
|
31 |
+
),
|
32 |
+
# Show a plot of the generated distribution
|
33 |
+
mainPanel(
|
34 |
+
plotOutput("distPlot")
|
35 |
+
)
|
36 |
+
)
|
37 |
+
))
|