Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
server.R
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
shinyServer(function(input, output) {
|
| 2 |
+
|
| 3 |
+
output$grafico1 <- renderPlot({
|
| 4 |
+
if (input$min > input$max) {
|
| 5 |
+
plot(c(-5, 5), c(0, 1), xlab="", ylab="", type='n',
|
| 6 |
+
xaxt='n', yaxt='n', bty='n')
|
| 7 |
+
text(x=0, y=0.5, col='red', cex=2,
|
| 8 |
+
label='Revise los valores que ingres贸.')
|
| 9 |
+
text(x=0, y=0.4, col='purple', cex=2,
|
| 10 |
+
label='El m铆nimo no puede ser mayor que el m谩ximo.')
|
| 11 |
+
}
|
| 12 |
+
else {
|
| 13 |
+
curve(dunif(x, min=input$min, max=input$max),
|
| 14 |
+
from=input$min, to=input$max, ylab="Densidad",
|
| 15 |
+
las=1, lwd=3, col="deepskyblue3")
|
| 16 |
+
grid()
|
| 17 |
+
}
|
| 18 |
+
})
|
| 19 |
+
|
| 20 |
+
output$med_var <- renderText({
|
| 21 |
+
if (input$min > input$max) {
|
| 22 |
+
paste(c("Hay algo errado!!!"))
|
| 23 |
+
}
|
| 24 |
+
else {
|
| 25 |
+
esperanza <- (input$min + input$max) / 2
|
| 26 |
+
varianza <- (input$max - input$min)^2 / 12
|
| 27 |
+
paste(c("Para esta configuraci贸n E(X) =", round(esperanza, 2),
|
| 28 |
+
"con Var(X) =", round(varianza, 2)))
|
| 29 |
+
}
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
})
|
ui.R
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
library(shiny)
|
| 2 |
+
|
| 3 |
+
shinyUI(fluidPage(
|
| 4 |
+
|
| 5 |
+
# Application title
|
| 6 |
+
titlePanel("Distribuci贸n uniforme continua"),
|
| 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 = "min",
|
| 14 |
+
label = "Valor m铆nimo",
|
| 15 |
+
min = -20,
|
| 16 |
+
max = 20,
|
| 17 |
+
value = 2,
|
| 18 |
+
step= 0.1,
|
| 19 |
+
animate = TRUE),
|
| 20 |
+
sliderInput(inputId = "max",
|
| 21 |
+
label = "Valor m谩ximo",
|
| 22 |
+
min = -20,
|
| 23 |
+
max = 20,
|
| 24 |
+
value = 5,
|
| 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 uniforme", align = "center"),
|
| 36 |
+
plotOutput("grafico1"),
|
| 37 |
+
verbatimTextOutput('med_var')
|
| 38 |
+
)
|
| 39 |
+
)
|
| 40 |
+
))
|