-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.R
57 lines (52 loc) · 1.35 KB
/
App.R
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
47
48
49
50
51
52
53
54
55
56
57
library(rsconnect)
library(shiny)
library(ggplot2)
library(dplyr)
url <- "http://deanattali.com/files/bcl-data.csv"
bc1 <- read.csv(url)
ui <- fluidPage(
titlePanel("BC Liquor Store prices"),
sidebarLayout(
sidebarPanel(
sliderInput("priceInput", "Price", min = 0, max = 100, value = c(25, 40), pre = "$"),
radioButtons("typeInput", "Product type",
choices = c("BEER", "REFRESHMENT", "SPIRITS", "WINE"),
selected = "WINE"),
uiOutput("countryOutput")
),
mainPanel(
plotOutput("coolplot"),
br(), br(),
tableOutput("results")
)
)
)
server <- function(input, output, session){
filtered <- reactive({
if(is.null(input$countryInput)) {
return(NULL)
}
bc1 %>%
filter(Price >= input$priceInput[1],
Price <= input$priceInput[2],
Type == input$typeInput,
Country == input$countryInput
)
})
output$coolplot <- renderPlot({
if (is.null(filtered())) {
return()
}
ggplot(filtered(), aes(Alcohol_Content)) +
geom_histogram()
})
output$results <- renderTable({
filtered()
})
output$countryOutput <- renderUI({
selectInput("countryInput", "Country",
sort(unique(bc1$Country)),
selected = "CANADA")
})
}
shinyApp(ui = ui, server = server)