FreddyHernandez commited on
Commit
f4191b8
1 Parent(s): b49f699

Upload 2 files

Browse files
Files changed (2) hide show
  1. server.R +20 -0
  2. ui.R +38 -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(dexp(x, rate=input$rate),
8
+ from=0, to=input$x_max, ylab="Density",
9
+ las=1, lwd=3, col="deepskyblue3")
10
+ grid()
11
+ })
12
+
13
+ output$med_var <- renderText({
14
+ esperanza <- 1/input$rate
15
+ varianza <- 1/input$rate^2
16
+ paste(c("For this configuration E(X) =", round(esperanza, 2),
17
+ "and Var(X) =", round(varianza, 2)))
18
+ })
19
+
20
+ })
ui.R ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ shinyUI(fluidPage(
4
+
5
+ # Application title
6
+ titlePanel(HTML("Exponential distribution (&lambda;)")),
7
+
8
+ sidebarLayout(
9
+ sidebarPanel(
10
+ HTML("Modify the parameter value and observe what happens with the density plot"),
11
+ br(),
12
+ br(),
13
+ sliderInput(inputId = "rate",
14
+ label = HTML("Enter the value of the rate parameter &lambda;: "),
15
+ min = 0.1,
16
+ max = 50,
17
+ value = 1.7,
18
+ step= 0.1,
19
+ animate = TRUE),
20
+ numericInput(inputId = "x_max",
21
+ label = "Enter the maximum value of x to display on the graph:",
22
+ min = 1,
23
+ max = 300,
24
+ value = 9,
25
+ step = 1),
26
+ br(),
27
+ p("App created by Semillero de R at Universidad Nacional de Colombia:"),
28
+ tags$a(href="https://srunal.github.io", "https://srunal.github.io")
29
+ ),
30
+
31
+ # Show a plot of the generated distribution
32
+ mainPanel(
33
+ h3("Density plot", align = "center"),
34
+ plotOutput("grafico1"),
35
+ verbatimTextOutput('med_var')
36
+ )
37
+ )
38
+ ))