FreddyHernandez commited on
Commit
9da1728
1 Parent(s): 16fef1d

Upload 2 files

Browse files
Files changed (2) hide show
  1. server.R +20 -0
  2. ui.R +48 -0
server.R ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ shinyServer(function(input, output)
4
+ {
5
+
6
+ output$grafico1 <- renderPlot({
7
+ curve(dgamma(x, shape=input$shape, scale=input$scale),
8
+ from=0, to=input$x.max, ylab="Densidad",
9
+ las=1, lwd=3, col="deepskyblue3")
10
+ grid()
11
+ })
12
+
13
+ output$med_var <- renderText({
14
+ esperanza <- (input$shape) * input$scale
15
+ varianza <- (input$shape) * input$scale^2
16
+ paste(c("Para esta configuración E(X) =", round(esperanza, 2),
17
+ "con Var(X) =", round(varianza, 2)))
18
+ })
19
+
20
+ })
ui.R ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ shinyUI(fluidPage(
4
+
5
+ # Application title
6
+ titlePanel("Distribución gamma"),
7
+
8
+ sidebarLayout(
9
+ sidebarPanel(
10
+ HTML("Modifique los valores de los parámetros y
11
+ observe lo que sucede con la densidad."),
12
+ br(),
13
+ br(),
14
+ sliderInput(inputId = "shape",
15
+ label = HTML("Ingrese el valor del parámetro shape:"),
16
+ min = 0.1,
17
+ max = 30,
18
+ value = 1.7,
19
+ step= 0.1,
20
+ animate = TRUE),
21
+ sliderInput(inputId = "scale",
22
+ label = HTML("Ingrese el valor del parámetro scale:"),
23
+ min = 0.1,
24
+ max = 30,
25
+ value = 1.5,
26
+ step= 0.1,
27
+ animate = TRUE),
28
+ sliderInput(inputId = "x.max",
29
+ label = "Ingrese el máximo valor de x para
30
+ mostrar en el gráfico:",
31
+ min = 1,
32
+ max = 300,
33
+ value = 9,
34
+ step = 1),
35
+ br(),
36
+ p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
37
+ tags$a(href="https://srunal.github.io",
38
+ "https://srunal.github.io")
39
+ ),
40
+
41
+ # Show a plot of the generated distribution
42
+ mainPanel(
43
+ h3("Densidad para la distribución gamma", align = "center"),
44
+ plotOutput("grafico1"),
45
+ verbatimTextOutput('med_var')
46
+ )
47
+ )
48
+ ))