FreddyHernandez commited on
Commit
9cd4d47
1 Parent(s): 62a5b47

Upload 2 files

Browse files
Files changed (2) hide show
  1. server.R +19 -0
  2. ui.R +37 -0
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 &lambda; 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, &lambda;:"),
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
+ ))