-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.R
71 lines (59 loc) · 1.79 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
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(ggplot2)
library(dplyr)
gapminder <- readRDS("gapminder.rds")
source("workshopFunctions.R")
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Gapminder plot"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("year",
"Select year",
min = min(gapminder$year),
max = max(gapminder$year),
value = min(gapminder$year),
sep="", # Hide thousands , separator
step=1, # Select every year
animate = animationOptions(interval = 1250)
),
checkboxGroupInput("continent",
"Select continents",
choices = levels(gapminder$continent),
selected = levels(gapminder$continent))
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("gapminderPlot"),
tableOutput("graphData")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
plotData <- reactive({
gapminder %>%
filter(year == input$year) %>%
filter(continent %in% input$continent)
})
output$graphData <- renderTable({
plotData() %>%
getRichestCountry()
})
output$gapminderPlot <- renderPlot({
plotData() %>%
produceGapminderPlot()
})
}
# Run the application
shinyApp(ui = ui, server = server)