-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
46 lines (34 loc) · 1.21 KB
/
app.R
File metadata and controls
46 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
library(shiny)
ui <- fluidPage(
pageWithSidebar(
headerPanel("My First Shiny App"),
sidebarPanel(
selectInput("Distribution", "Select distribution Type",
choices = c("Normal", "Exponential")),
sliderInput("SampleSize", "Please select the sample size",
min= 100, max = 5000, step = 100, value = 1000),
conditionalPanel(condition = "input.Distribution == 'Normal'",
textInput("Mean","Please enter the mean", 10),
textInput("Sd","Please enter the standard deviation",3)),
conditionalPanel(condition = "input.Distribution == 'Exponential'",
textInput("Lambda","Please enter the lambda", 1))
),
mainPanel(
plotOutput("myPlot")
)
)
)
server <- function(input, output){
output$myPlot <- renderPlot({
disType <- input$Distribution
size <- input$SampleSize
if(disType == "Normal"){
randvec <- rnorm(size, mean= as.numeric(input$Mean), sd=as.numeric(input$Sd))
}
else{
randvec <-rexp(size, rate = 1/as.numeric(input$Lambda))
}
hist(randvec, col="blue")
})
}
shinyApp(ui=ui , server = server)