Spaces:
Sleeping
Sleeping
Commit
路
40d6528
1
Parent(s):
ceafc45
Upload 2 files
Browse files
server.R
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
n <- input$max - input$min + 1
|
14 |
+
x <- seq(from=input$min, to=input$max)
|
15 |
+
prob <- rep(1/n, n)
|
16 |
+
barplot(prob, ylim=c(0, 1), names.arg=x,
|
17 |
+
xlab="x", ylab=expression(P(X==x)),
|
18 |
+
col="deepskyblue3", las=1)
|
19 |
+
grid()
|
20 |
+
}
|
21 |
+
})
|
22 |
+
})
|
ui.R
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
library(shiny)
|
2 |
+
|
3 |
+
shinyUI(fluidPage(
|
4 |
+
|
5 |
+
# Application title
|
6 |
+
titlePanel("Distribuci贸n uniforme discreta"),
|
7 |
+
|
8 |
+
sidebarLayout(
|
9 |
+
sidebarPanel(
|
10 |
+
p("Modifique los valores de los par谩metros y observe
|
11 |
+
lo que sucede en el diagrama"),
|
12 |
+
br(),
|
13 |
+
sliderInput(inputId = "min",
|
14 |
+
label = "Valor m铆nimo",
|
15 |
+
min = -20,
|
16 |
+
max = 20,
|
17 |
+
value = 2,
|
18 |
+
step= 1,
|
19 |
+
animate = TRUE),
|
20 |
+
sliderInput(inputId = "max",
|
21 |
+
label = "Valor m谩ximo",
|
22 |
+
min = -20,
|
23 |
+
max = 20,
|
24 |
+
value = 5,
|
25 |
+
step= 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("Diagrama de barras para las probabilidades", align = "center"),
|
36 |
+
plotOutput("grafico1")
|
37 |
+
)
|
38 |
+
)
|
39 |
+
))
|