osanseviero commited on
Commit
a2b2686
·
1 Parent(s): 907d316

Create app.R

Browse files
Files changed (1) hide show
  1. app.R +39 -0
app.R ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(shiny)
2
+
3
+ # Define UI for application that draws a histogram
4
+ ui <- fluidPage(
5
+
6
+ # Application title
7
+ titlePanel("Old Faithful Geyser Data"),
8
+
9
+ # Sidebar with a slider input for number of bins
10
+ sidebarLayout(
11
+ sidebarPanel(
12
+ sliderInput("bins",
13
+ "Number of bins:",
14
+ min = 1,
15
+ max = 50,
16
+ value = 30)
17
+ ),
18
+
19
+ # Show a plot of the generated distribution
20
+ mainPanel(
21
+ plotOutput("distPlot")
22
+ )
23
+ )
24
+ )
25
+
26
+ # Define server logic required to draw a histogram
27
+ server <- function(input, output) {
28
+
29
+ output$distPlot <- renderPlot({
30
+ # generate bins based on input$bins from ui.R
31
+ x <- faithful[, 2]
32
+ bins <- seq(min(x), max(x), length.out = input$bins + 1)
33
+
34
+ # draw the histogram with the specified number of bins
35
+ hist(x, breaks = bins, col = 'darkgray', border = 'white')
36
+ })
37
+ }
38
+
39
+ shinyApp(ui = ui, server = server)