Spaces:
Sleeping
Sleeping
FreddyHernandez
commited on
Commit
•
39c971f
1
Parent(s):
f4fdd8e
Upload 2 files
Browse files
server.R
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyServer(function(input, output)
|
4 |
+
{
|
5 |
+
|
6 |
+
output$grafico1 <- renderPlot({
|
7 |
+
esperanza <-exp(input$mu+((input$sigma)^2)/2)
|
8 |
+
varianza <-(exp(input$sigma^2)-1)*exp(2*input$mu+((input$sigma)^2))
|
9 |
+
curve(dlnorm(x, input$mu, input$sigma),
|
10 |
+
from=0, to=esperanza+3*sqrt(varianza), ylab="Densidad",
|
11 |
+
las=1, lwd=3, col="deepskyblue3")
|
12 |
+
grid()
|
13 |
+
})
|
14 |
+
|
15 |
+
output$med_var <- renderText({
|
16 |
+
esperanza <-exp(input$mu+((input$sigma)^2)/2)
|
17 |
+
varianza <-(exp(input$sigma^2)-1)*exp(2*input$mu+((input$sigma)^2))
|
18 |
+
paste(c("Para esta configuración E(X)=", round(esperanza, 2),
|
19 |
+
"y Var(X)=", round(varianza,2)))
|
20 |
+
})
|
21 |
+
|
22 |
+
})
|
ui.R
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyUI(fluidPage(
|
4 |
+
|
5 |
+
# Application title
|
6 |
+
titlePanel("Distribución log-normal"),
|
7 |
+
|
8 |
+
sidebarLayout(
|
9 |
+
sidebarPanel(
|
10 |
+
p("Modifique los valores de los parámetros y observe
|
11 |
+
lo que sucede con la densidad."),
|
12 |
+
br(),
|
13 |
+
sliderInput(inputId = "mu",
|
14 |
+
label = HTML("Ingrese el valor de μ (meanlog):"),
|
15 |
+
min = 0,
|
16 |
+
max = 30,
|
17 |
+
value = 0.7,
|
18 |
+
step= 0.1,
|
19 |
+
animate =TRUE),
|
20 |
+
sliderInput(inputId = "sigma",
|
21 |
+
label = HTML("Ingrese el valor de σ (sdlog): "),
|
22 |
+
min = 0.1,
|
23 |
+
max = 30,
|
24 |
+
value = 0.3,
|
25 |
+
step= 0.1,
|
26 |
+
animate =TRUE),
|
27 |
+
br(),
|
28 |
+
p("App creada por el Semillero de R de la Universidad Nacional de Colombia:"),
|
29 |
+
tags$a(href="https://srunal.github.io/",
|
30 |
+
"https://srunal.github.io/")
|
31 |
+
),
|
32 |
+
|
33 |
+
# Show a plot of the generated distribution
|
34 |
+
mainPanel(
|
35 |
+
h3("Densidad para la distribución log-normal", align = "center"),
|
36 |
+
plotOutput("grafico1"),
|
37 |
+
verbatimTextOutput('med_var')
|
38 |
+
)
|
39 |
+
)
|
40 |
+
))
|