├── Examples ├── 09_ReactiveFileReader │ ├── data.csv │ ├── ui.R │ └── server.R ├── 08_Scheduling │ ├── ui.R │ └── server.R ├── 13_InteractiveGraphics │ ├── ui.R │ └── server.R ├── 14_Zoom │ ├── ui.R │ └── server.R ├── 10_Modules │ ├── app.R │ └── summaryByTime.R ├── 01_BasicReactive │ ├── server.R │ └── ui.R ├── 02_ReactiveExpression │ ├── server.R │ └── ui.R ├── 04_EventReactive │ ├── server.R │ └── ui.R ├── 03_Isolate │ ├── server.R │ └── ui.R ├── 07_Update │ ├── ui.R │ └── server.R ├── 05_Observe │ ├── server.R │ └── ui.R ├── 06_ReactiveValues │ ├── server.R │ └── ui.R ├── 11_ModuleInput │ ├── app.R │ └── summaryByTime.R ├── 15_gadget │ └── ggbrush.R ├── 12_ModuleOutput │ ├── app.R │ └── summaryByTime.R └── 16_Bookmark │ └── app.R └── Exercises ├── 06_Time ├── ui.R └── server.R ├── 08_Modules2 ├── app.R └── columnByMonth.R ├── 07_Modules1 ├── app.R └── columnByMonth.R ├── 01_ReactiveApp ├── ui.R └── server.R ├── 02_ReactiveApp ├── ui.R └── server.R ├── 03_Update ├── ui.R └── server.R ├── 04_EventReactive ├── ui.R └── server.R ├── 05_UpdateInputs ├── ui.R └── server.R └── 09_Modules3 ├── columnByMonth.R └── app.R /Examples/09_ReactiveFileReader/data.csv: -------------------------------------------------------------------------------- 1 | X,Y 2 | 1,-2.0670815468016666 3 | 2,-0.6912923670167842 4 | 3,-0.2365301879921714 5 | 4,-0.11012689160796152 6 | 5,-0.30344422534861293 7 | 6,2.0685587444237816 8 | 7,-0.34353275209053663 9 | 8,0.10127182174984647 10 | 9,-0.3440438963847039 11 | 10,1.9123022114225414 12 | -------------------------------------------------------------------------------- /Exercises/06_Time/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 6 - Time 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | 11 | textOutput("time") 12 | 13 | )) -------------------------------------------------------------------------------- /Examples/08_Scheduling/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 8- Scheduling 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 6, 11 | plotOutput("simHist") 12 | ), 13 | column(width = 6, 14 | tableOutput("dataSummary") 15 | )) 16 | )) -------------------------------------------------------------------------------- /Examples/09_ReactiveFileReader/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 9 - Reactive File Reader 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 6, 11 | plotOutput("simHist") 12 | ), 13 | column(width = 6, 14 | tableOutput("dataSummary") 15 | )) 16 | )) -------------------------------------------------------------------------------- /Exercises/08_Modules2/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 8 - Modules 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | source("columnByMonth.R") 9 | 10 | ui <- fluidPage( 11 | 12 | columnByMonthUI("allData") 13 | 14 | ) 15 | 16 | 17 | server <- function(input, output, session){ 18 | 19 | callModule(columnByMonth, "allData") 20 | 21 | } 22 | 23 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Examples/13_InteractiveGraphics/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 13 - Interactive Graphics 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 7, 11 | plotOutput("pkPoints", brush = "brushPK") 12 | ), 13 | column(width = 7, 14 | tableOutput("selectedData") 15 | )) 16 | )) -------------------------------------------------------------------------------- /Examples/14_Zoom/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 13 - Interactive Graphics 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 7, 11 | plotOutput("pkPoints", brush = "brushPK", dblclick = "clickPK") 12 | ), 13 | column(width = 7, 14 | tableOutput("selectedData") 15 | )) 16 | )) -------------------------------------------------------------------------------- /Exercises/06_Time/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 6 - Time 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | library(tidyverse) 10 | library(lubridate) 11 | theme_set(theme_bw(base_size = 16)) 12 | 13 | function(input, output, session){ 14 | 15 | output$time <- renderPrint({ 16 | 17 | invalidateLater(1000) 18 | 19 | now() 20 | 21 | }) 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Examples/10_Modules/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 10 - Modules 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | library(ggplot2) 9 | library(broom) 10 | source("summaryByTime.R") 11 | 12 | ui <- fluidPage( 13 | 14 | summaryByTimeUI("allData") 15 | 16 | ) 17 | 18 | server <- function(input, output, session){ 19 | 20 | callModule(summaryByTime, "allData") 21 | 22 | } 23 | 24 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Exercises/07_Modules1/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 7 - Modules 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | 9 | ui <- fluidPage( 10 | 11 | 12 | 13 | ) 14 | 15 | 16 | server <- function(input, output){ 17 | 18 | output$tubePlot <- renderPlot( 19 | 20 | ggplot(aes_string("Month", input$column), data = tubeData) + 21 | geom_point() 22 | 23 | ) 24 | 25 | } 26 | 27 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Exercises/07_Modules1/columnByMonth.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 7 - Modules 5 | #------------------------------------------------------------------------------# 6 | 7 | columnByMonthUI <- function(id){ 8 | 9 | ns <- NS(id) 10 | 11 | tagList( 12 | 13 | fluidRow(column(width = 3, 14 | selectInput(ns("column"), "Select Column:", 15 | choices = c("TOTAL", "Excess", "Scheduled")))), 16 | 17 | fluidRow(plotOutput(ns("tubePlot"))) 18 | 19 | ) 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Exercises/01_ReactiveApp/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | selectInput("data", "Choose Data", 12 | choices = c("Iris", "Airquality", "Mtcars")) 13 | )), 14 | 15 | fluidRow(column(width = 6, 16 | plotOutput("twoColumnPlot") 17 | ), 18 | column(width = 6, 19 | tableOutput("dataSummary") 20 | )) 21 | )) -------------------------------------------------------------------------------- /Exercises/02_ReactiveApp/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 2 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | selectInput("data", "Choose Data", 12 | choices = c("Iris", "Airquality", "Mtcars")) 13 | )), 14 | 15 | fluidRow(column(width = 6, 16 | plotOutput("twoColumnPlot") 17 | ), 18 | column(width = 6, 19 | tableOutput("dataSummary") 20 | )) 21 | )) -------------------------------------------------------------------------------- /Examples/01_BasicReactive/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | output$simHist <- renderPlot({ 14 | 15 | x <- rnorm(input$nSims) 16 | qplot(x, bins = 20, fill = I(input$col)) 17 | 18 | }) 19 | 20 | output$dataSummary <- renderTable({ 21 | 22 | x <- rnorm(input$nSims) 23 | tidy(summary(x)) 24 | 25 | }) 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Exercises/03_Update/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 3 - Update 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | selectInput("data", "Choose Data", 12 | choices = c("Iris", "Airquality", "Mtcars")) 13 | ), 14 | column(width = 3, 15 | actionButton("update", "Update!") 16 | ) 17 | ), 18 | 19 | fluidRow(column(width = 6, 20 | plotOutput("twoColumnPlot") 21 | ), 22 | column(width = 6, 23 | tableOutput("dataSummary") 24 | )) 25 | )) -------------------------------------------------------------------------------- /Examples/08_Scheduling/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 8 - Scheduling 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | data <- reactive({ 14 | 15 | invalidateLater(2000) 16 | rnorm(500) 17 | 18 | }) 19 | 20 | output$simHist <- renderPlot({ 21 | 22 | x <- data() 23 | qplot(x, bins = 20) 24 | 25 | }) 26 | 27 | output$dataSummary <- renderTable({ 28 | 29 | x <- data() 30 | tidy(summary(x)) 31 | 32 | }) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Examples/13_InteractiveGraphics/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 13 - Interactive Graphics 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | library(mangoTraining) 10 | theme_set(theme_bw(base_size = 16)) 11 | 12 | function(input, output){ 13 | 14 | output$pkPoints <- renderPlot({ 15 | 16 | qplot(Weight, Height, data = demoData) 17 | 18 | }) 19 | 20 | output$selectedData <- renderTable({ 21 | 22 | brushedPoints(demoData, input$brushPK, 23 | xvar = "Weight", yvar = "Height") 24 | 25 | 26 | }) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Exercises/04_EventReactive/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 4 - Event Reactive 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | selectInput("data", "Choose Data", 12 | choices = c("Iris", "Airquality", "Mtcars")) 13 | ), 14 | column(width = 3, 15 | actionButton("update", "Update!") 16 | ) 17 | ), 18 | 19 | fluidRow(column(width = 6, 20 | plotOutput("twoColumnPlot") 21 | ), 22 | column(width = 6, 23 | tableOutput("dataSummary") 24 | )) 25 | )) -------------------------------------------------------------------------------- /Examples/02_ReactiveExpression/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | data <- reactive({ 14 | 15 | rnorm(input$nSims) 16 | 17 | }) 18 | 19 | output$simHist <- renderPlot({ 20 | 21 | x <- data() 22 | qplot(x, bins = 20, fill = I(input$col)) 23 | 24 | }) 25 | 26 | output$dataSummary <- renderTable({ 27 | 28 | x <- data() 29 | tidy(summary(x)) 30 | 31 | }) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Examples/04_EventReactive/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 3 - Isolate 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | data <- eventReactive(input$run, { 14 | 15 | rnorm(input$nSims) 16 | 17 | }) 18 | 19 | output$simHist <- renderPlot({ 20 | 21 | x <- data() 22 | qplot(x, bins = 20, fill = I(input$col)) 23 | 24 | }) 25 | 26 | output$dataSummary <- renderTable({ 27 | 28 | x <- data() 29 | tidy(summary(x)) 30 | 31 | }) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Examples/03_Isolate/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 3 - Isolate 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | data <- reactive({ 14 | 15 | rnorm(input$nSims) 16 | 17 | }) 18 | 19 | output$simHist <- renderPlot({ 20 | 21 | x <- data() 22 | qplot(x, bins = 20, fill = I(input$col)) 23 | 24 | }) 25 | 26 | output$dataSummary <- renderTable({ 27 | 28 | input$run 29 | x <- isolate(data()) 30 | tidy(summary(x)) 31 | 32 | }) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Exercises/05_UpdateInputs/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 5 - Update Inputs 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | fileInput("data", "Choose Data") 12 | ), 13 | column(width = 3, 14 | selectInput("xaxis", "Select X axis Column:", choices = NULL) 15 | ), 16 | column(width = 3, 17 | selectInput("yaxis", "Select Y axis Column:", choices = NULL) 18 | ) 19 | ), 20 | 21 | fluidRow(column(width = 6, 22 | plotOutput("twoColumnPlot") 23 | ), 24 | column(width = 6, 25 | tableOutput("dataSummary") 26 | )) 27 | )) -------------------------------------------------------------------------------- /Examples/01_BasicReactive/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | selectInput("col", "Histogram Colour:", 14 | choices = colors(), selected = "black") 15 | )), 16 | 17 | fluidRow(column(width = 6, 18 | plotOutput("simHist") 19 | ), 20 | column(width = 6, 21 | tableOutput("dataSummary") 22 | )) 23 | )) -------------------------------------------------------------------------------- /Examples/02_ReactiveExpression/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | selectInput("col", "Histogram Colour:", 14 | choices = colors(), selected = "black") 15 | )), 16 | 17 | fluidRow(column(width = 7, 18 | plotOutput("simHist") 19 | ), 20 | column(width = 7, 21 | tableOutput("dataSummary") 22 | )) 23 | )) -------------------------------------------------------------------------------- /Examples/09_ReactiveFileReader/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 9 - Reactive File Reader 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | library(readr) 10 | theme_set(theme_bw(base_size = 16)) 11 | 12 | function(input, output, session){ 13 | 14 | data <- reactiveFileReader(5000, 15 | session, 16 | "data.csv", 17 | read_csv) 18 | 19 | output$simHist <- renderPlot({ 20 | 21 | x <- data() 22 | qplot(X, Y, data = x, geom = "line") 23 | 24 | }) 25 | 26 | output$dataSummary <- renderTable({ 27 | 28 | x <- data() 29 | tidy(summary(x$Y)) 30 | 31 | }) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Exercises/08_Modules2/columnByMonth.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 8 - Modules 5 | #------------------------------------------------------------------------------# 6 | 7 | columnByMonthUI <- function(id){ 8 | 9 | ns <- NS(id) 10 | 11 | tagList( 12 | 13 | 14 | fluidRow(column(width = 3, 15 | selectInput(ns("column"), "Select Column:", 16 | choices = c("TOTAL", "Excess", "Scheduled")))), 17 | 18 | fluidRow(plotOutput(ns("tubePlot"))) 19 | 20 | ) 21 | 22 | } 23 | 24 | 25 | 26 | columnByMonth <- function(input, output, session){ 27 | 28 | output$tubePlot <- renderPlot( 29 | 30 | ggplot(aes_string("Month", input$column), data = tubeData) + 31 | geom_point() 32 | 33 | ) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Exercises/09_Modules3/columnByMonth.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 9 - Modules 5 | #------------------------------------------------------------------------------# 6 | 7 | columnByMonthUI <- function(id){ 8 | 9 | ns <- NS(id) 10 | 11 | tagList( 12 | 13 | 14 | fluidRow(column(width = 3, 15 | selectInput(ns("column"), "Select Column:", 16 | choices = c("TOTAL", "Excess", "Scheduled")))), 17 | 18 | fluidRow(plotOutput(ns("tubePlot"))) 19 | 20 | ) 21 | 22 | } 23 | 24 | 25 | 26 | columnByMonth <- function(input, output, session, data){ 27 | 28 | output$tubePlot <- renderPlot( 29 | 30 | ggplot(aes_string("Month", input$column), data = data) + 31 | geom_point() 32 | 33 | ) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Examples/07_Update/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 7- Update 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | selectInput("col", "Histogram Colour:", 14 | choices = colors(), selected = "black"), 15 | actionButton("reset", "Reset") 16 | )), 17 | 18 | fluidRow(column(width = 6, 19 | plotOutput("simHist") 20 | ), 21 | column(width = 6, 22 | tableOutput("dataSummary") 23 | )) 24 | )) -------------------------------------------------------------------------------- /Examples/03_Isolate/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 3 - Isolate 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | actionButton("run", "Run Summary"), 14 | selectInput("col", "Histogram Colour:", 15 | choices = colors(), selected = "black") 16 | )), 17 | 18 | fluidRow(column(width = 6, 19 | plotOutput("simHist") 20 | ), 21 | column(width = 6, 22 | tableOutput("dataSummary") 23 | )) 24 | )) -------------------------------------------------------------------------------- /Examples/04_EventReactive/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 3 - Isolate 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | actionButton("run", "Run Summary"), 14 | selectInput("col", "Histogram Colour:", 15 | choices = colors(), selected = "black") 16 | )), 17 | 18 | fluidRow(column(width = 6, 19 | plotOutput("simHist") 20 | ), 21 | column(width = 6, 22 | tableOutput("dataSummary") 23 | )) 24 | )) -------------------------------------------------------------------------------- /Examples/07_Update/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 7 - Update 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output, session){ 12 | 13 | observeEvent(input$reset, { 14 | updateSelectInput(session, "col", selected = "black") 15 | updateSliderInput(session, "nSims", value = 500) 16 | }) 17 | 18 | data <- reactive({ 19 | 20 | rnorm(input$nSims) 21 | 22 | }) 23 | 24 | output$simHist <- renderPlot({ 25 | 26 | x <- data() 27 | qplot(x, bins = 20, fill = I(input$col)) 28 | 29 | }) 30 | 31 | output$dataSummary <- renderTable({ 32 | 33 | x <- data() 34 | tidy(summary(x)) 35 | 36 | }) 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Exercises/02_ReactiveApp/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 2 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | selectedData <- reactive({ 14 | 15 | switch(input$data, 16 | "Iris" = iris, 17 | "Airquality" = airquality, 18 | "Mtcars" = mtcars) 19 | 20 | }) 21 | 22 | output$twoColumnPlot <- renderPlot({ 23 | 24 | data <- selectedData() 25 | 26 | qplot(x = data[,1], y = data[,2]) 27 | 28 | }) 29 | 30 | output$dataSummary <- renderTable({ 31 | 32 | data <- selectedData() 33 | 34 | tidy(summary(data[,2])) 35 | 36 | }) 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Examples/05_Observe/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 5 - Observe Event 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | reactData <- reactiveValues(data = rnorm(100)) 14 | 15 | observeEvent(input$norm, { 16 | reactData$data <- rnorm(input$nSims) 17 | }) 18 | 19 | observeEvent(input$unif, { 20 | reactData$data <- runif(input$nSims) 21 | }) 22 | 23 | output$simHist <- renderPlot({ 24 | 25 | x <- reactData$data 26 | qplot(x, bins = 20, fill = I(input$col)) 27 | 28 | }) 29 | 30 | output$dataSummary <- renderTable({ 31 | 32 | x <- reactData$data 33 | tidy(summary(x)) 34 | 35 | }) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Examples/06_ReactiveValues/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 6 - Reactive Values 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | reactData <- reactiveValues(data = rnorm(100)) 14 | 15 | observeEvent(input$norm, { 16 | reactData$data <- rnorm(input$nSims) 17 | }) 18 | 19 | observeEvent(input$unif, { 20 | reactData$data <- runif(input$nSims) 21 | }) 22 | 23 | output$simHist <- renderPlot({ 24 | 25 | x <- reactData$data 26 | qplot(x, bins = 20, fill = I(input$col)) 27 | 28 | }) 29 | 30 | output$dataSummary <- renderTable({ 31 | 32 | x <- reactData$data 33 | tidy(summary(x)) 34 | 35 | }) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Exercises/04_EventReactive/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 4 - Event Reactive 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | selectedData <- eventReactive(input$update, { 14 | 15 | switch(input$data, 16 | "Iris" = iris, 17 | "Airquality" = airquality, 18 | "Mtcars" = mtcars) 19 | 20 | }) 21 | 22 | output$twoColumnPlot <- renderPlot({ 23 | 24 | data <- selectedData() 25 | 26 | qplot(x = data[,1], y = data[,2]) 27 | 28 | }) 29 | 30 | output$dataSummary <- renderTable({ 31 | 32 | data <- selectedData() 33 | 34 | tidy(summary(data[,2])) 35 | 36 | }) 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Exercises/03_Update/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 3 - Update 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | selectedData <- reactive({ 14 | 15 | switch(input$data, 16 | "Iris" = iris, 17 | "Airquality" = airquality, 18 | "Mtcars" = mtcars) 19 | 20 | }) 21 | 22 | output$twoColumnPlot <- renderPlot({ 23 | 24 | input$update 25 | 26 | data <- isolate(selectedData()) 27 | 28 | qplot(x = data[,1], y = data[,2]) 29 | 30 | }) 31 | 32 | output$dataSummary <- renderTable({ 33 | 34 | data <- selectedData() 35 | 36 | tidy(summary(data[,2])) 37 | 38 | }) 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Examples/05_Observe/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 5 - Observe Event 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | actionButton("norm", "Simulate Normal"), 14 | actionButton("unif", "Simulate Uniform"), 15 | selectInput("col", "Histogram Colour:", 16 | choices = colors(), selected = "black") 17 | )), 18 | 19 | fluidRow(column(width = 6, 20 | plotOutput("simHist") 21 | ), 22 | column(width = 6, 23 | tableOutput("dataSummary") 24 | )) 25 | )) -------------------------------------------------------------------------------- /Examples/06_ReactiveValues/ui.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 6 - Reactive Values 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | 8 | shinyUI(fluidPage( 9 | 10 | fluidRow(column(width = 3, 11 | sliderInput("nSims", "Number of Simulations:", 12 | min = 100, max = 1000, value = 500), 13 | actionButton("norm", "Simulate Normal"), 14 | actionButton("unif", "Simulate Uniform"), 15 | selectInput("col", "Histogram Colour:", 16 | choices = colors(), selected = "black") 17 | )), 18 | 19 | fluidRow(column(width = 6, 20 | plotOutput("simHist") 21 | ), 22 | column(width = 6, 23 | tableOutput("dataSummary") 24 | )) 25 | )) -------------------------------------------------------------------------------- /Exercises/01_ReactiveApp/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 1 - Basic Reactivity 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | function(input, output){ 12 | 13 | output$twoColumnPlot <- renderPlot({ 14 | 15 | data <- switch(input$data, 16 | "Iris" = iris, 17 | "Airquality" = airquality, 18 | "Mtcars" = mtcars) 19 | 20 | qplot(x = data[,1], y = data[,2]) 21 | 22 | }) 23 | 24 | output$dataSummary <- renderTable({ 25 | 26 | data <- switch(input$data, 27 | "Iris" = iris, 28 | "Airquality" = airquality, 29 | "Mtcars" = mtcars) 30 | 31 | tidy(summary(data[,2])) 32 | 33 | }) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Examples/11_ModuleInput/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 11 - Module Input 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | library(tidyverse) 9 | library(broom) 10 | source("summaryByTime.R") 11 | 12 | ui <- fluidPage( 13 | 14 | tabsetPanel( 15 | tabPanel("All Data", summaryByTimeUI("allData")), 16 | tabPanel("Dose 25", summaryByTimeUI("25")), 17 | tabPanel("Dose 50", summaryByTimeUI("50")), 18 | tabPanel("Dose 100", summaryByTimeUI("100")) 19 | ) 20 | 21 | 22 | ) 23 | 24 | server <- function(input, output, session){ 25 | 26 | callModule(summaryByTime, "allData", pkData) 27 | callModule(summaryByTime, "25", filter(pkData, Dose == 25)) 28 | callModule(summaryByTime, "50", filter(pkData, Dose == 50)) 29 | callModule(summaryByTime, "100", filter(pkData, Dose == 100)) 30 | 31 | } 32 | 33 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Examples/15_gadget/ggbrush.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(miniUI) 3 | library(ggplot2) 4 | 5 | ggbrush <- function(data, xvar, yvar) { 6 | 7 | ui <- miniPage( 8 | gadgetTitleBar("Drag to select points"), 9 | miniContentPanel( 10 | # The brush="brush" argument means we can listen for 11 | # brush events on the plot using input$brush. 12 | plotOutput("plot", height = "100%", brush = "brush") 13 | ) 14 | ) 15 | 16 | server <- function(input, output, session) { 17 | 18 | # Render the plot 19 | output$plot <- renderPlot({ 20 | # Plot the data with x/y vars indicated by the caller. 21 | ggplot(data, aes_string(xvar, yvar)) + geom_point() 22 | }) 23 | 24 | # Handle the Done button being pressed. 25 | observeEvent(input$done, { 26 | # Return the brushed points. See ?shiny::brushedPoints. 27 | stopApp(brushedPoints(data, input$brush)) 28 | }) 29 | } 30 | 31 | runGadget(ui, server, viewer = dialogViewer("Point Selection")) 32 | } 33 | 34 | ggbrush(demoData, "Weight", "Height") 35 | -------------------------------------------------------------------------------- /Examples/11_ModuleInput/summaryByTime.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # UI 3 | #------------------------------------------------------------------------------# 4 | summaryByTimeUI <- function(id){ 5 | 6 | ns <- NS(id) 7 | 8 | tagList( 9 | 10 | plotOutput(ns("timeConcPlot")), 11 | selectInput(ns("time"), "Select time:", choices = c(0, 1, 6, 12, 24)), 12 | tableOutput(ns("summary")) 13 | 14 | ) 15 | 16 | } 17 | 18 | #------------------------------------------------------------------------------# 19 | # Server 20 | #------------------------------------------------------------------------------# 21 | summaryByTime <- function(input, output, session, data){ 22 | 23 | output$timeConcPlot <- renderPlot({ 24 | 25 | qplot(Time, Conc, data = data, group = Subject, geom = "line") + 26 | geom_vline(xintercept = as.numeric(input$time), col = "red", size = 2) 27 | 28 | }) 29 | 30 | output$summary <- renderTable({ 31 | 32 | x <- data[data$Time == as.numeric(input$time), "Conc"] 33 | tidy(summary(x)) 34 | 35 | }) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Examples/12_ModuleOutput/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 11 - Module Input 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | library(tidyverse) 9 | library(broom) 10 | source("summaryByTime.R") 11 | 12 | ui <- fluidPage( 13 | 14 | textOutput("WhichTime"), 15 | 16 | tabsetPanel( 17 | tabPanel("All Data", summaryByTimeUI("allData")), 18 | tabPanel("Dose 25", summaryByTimeUI("25")), 19 | tabPanel("Dose 50", summaryByTimeUI("50")), 20 | tabPanel("Dose 100", summaryByTimeUI("100")) 21 | ) 22 | 23 | 24 | ) 25 | 26 | server <- function(input, output, session){ 27 | 28 | time <- callModule(summaryByTime, "allData", pkData) 29 | callModule(summaryByTime, "25", filter(pkData, Dose == 25)) 30 | callModule(summaryByTime, "50", filter(pkData, Dose == 50)) 31 | callModule(summaryByTime, "100", filter(pkData, Dose == 100)) 32 | 33 | output$WhichTime <- renderText({paste("Selected time is:", time())}) 34 | } 35 | 36 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Examples/10_Modules/summaryByTime.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # UI 3 | #------------------------------------------------------------------------------# 4 | summaryByTimeUI <- function(id){ 5 | 6 | ns <- NS(id) 7 | 8 | tagList( 9 | 10 | plotOutput(ns("timeConcPlot")), 11 | selectInput(ns("time"), "Select time:", choices = c(0, 1, 6, 12, 24)), 12 | tableOutput(ns("summary")) 13 | 14 | ) 15 | 16 | } 17 | 18 | #------------------------------------------------------------------------------# 19 | # Server 20 | #------------------------------------------------------------------------------# 21 | summaryByTime <- function(input, output, session){ 22 | 23 | data <- pkData 24 | 25 | output$timeConcPlot <- renderPlot({ 26 | 27 | qplot(Time, Conc, data = data, group = Subject, geom = "line") + 28 | geom_vline(xintercept = as.numeric(input$time), col = "red", size = 2) 29 | 30 | }) 31 | 32 | output$summary <- renderTable({ 33 | 34 | x <- data[data$Time == as.numeric(input$time), "Conc"] 35 | tidy(summary(x)) 36 | 37 | }) 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Examples/14_Zoom/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 13 - Interactive Graphics 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | library(mangoTraining) 10 | theme_set(theme_bw(base_size = 16)) 11 | 12 | function(input, output){ 13 | 14 | limits <- reactiveValues(x = NULL, y = NULL) 15 | 16 | output$pkPoints <- renderPlot({ 17 | 18 | qplot(Weight, Height, data = demoData) + 19 | coord_cartesian(limits$x, limits$y) 20 | 21 | }) 22 | 23 | output$selectedData <- renderTable({ 24 | 25 | brushedPoints(demoData, input$brushPK, 26 | xvar = "Weight", yvar = "Height") 27 | 28 | 29 | }) 30 | 31 | observeEvent(input$clickPK, { 32 | brush <- input$brushPK 33 | if (!is.null(brush)) { 34 | limits$x <- c(brush$xmin, brush$xmax) 35 | limits$y <- c(brush$ymin, brush$ymax) 36 | 37 | } else { 38 | limits$x <- NULL 39 | limits$y <- NULL 40 | } 41 | }) 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Examples/12_ModuleOutput/summaryByTime.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # UI 3 | #------------------------------------------------------------------------------# 4 | summaryByTimeUI <- function(id){ 5 | 6 | ns <- NS(id) 7 | 8 | tagList( 9 | 10 | plotOutput(ns("timeConcPlot")), 11 | selectInput(ns("time"), "Select time:", choices = c(0, 1, 6, 12, 24)), 12 | tableOutput(ns("summary")) 13 | 14 | ) 15 | 16 | } 17 | 18 | #------------------------------------------------------------------------------# 19 | # Server 20 | #------------------------------------------------------------------------------# 21 | summaryByTime <- function(input, output, session, data){ 22 | 23 | output$timeConcPlot <- renderPlot({ 24 | 25 | qplot(Time, Conc, data = data, group = Subject, geom = "line") + 26 | geom_vline(xintercept = as.numeric(input$time), col = "red", size = 2) 27 | 28 | }) 29 | 30 | output$summary <- renderTable({ 31 | 32 | x <- data[data$Time == as.numeric(input$time), "Conc"] 33 | tidy(summary(x)) 34 | 35 | }) 36 | 37 | reactive(input$time) 38 | } 39 | -------------------------------------------------------------------------------- /Exercises/05_UpdateInputs/server.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 5 - Update Inputs 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | library(tidyverse) 10 | theme_set(theme_bw(base_size = 16)) 11 | 12 | function(input, output, session){ 13 | 14 | selectedData <- reactive({ 15 | 16 | validate(need(!is.null(input$data), "Please upload a csv to continue")) 17 | 18 | file <- input$data$datapath 19 | 20 | data <- read_csv(file) 21 | 22 | updateSelectInput(session, "xaxis", choices = names(data)) 23 | updateSelectInput(session, "yaxis", choices = names(data)) 24 | 25 | data 26 | 27 | }) 28 | 29 | output$twoColumnPlot <- renderPlot({ 30 | 31 | data <- selectedData() 32 | 33 | ggplot(aes_string(x = input$xaxis, y = input$yaxis), data = data) + 34 | geom_point() 35 | 36 | }) 37 | 38 | output$dataSummary <- renderTable({ 39 | 40 | data <- selectedData() %>% as.data.frame() 41 | 42 | tidy(summary(data[,input$yaxis])) 43 | 44 | }) 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Examples/16_Bookmark/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Example 16 - Bookmarking 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(ggplot2) 8 | library(broom) 9 | theme_set(theme_bw(base_size = 16)) 10 | 11 | 12 | ui <- function(request){ 13 | 14 | fluidPage( 15 | 16 | fluidRow(column(width = 3, 17 | sliderInput("nSims", "Number of Simulations:", 18 | min = 100, max = 1000, value = 500)), 19 | column(width = 3, 20 | selectInput("col", "Histogram Colour:", 21 | choices = colors(), selected = "black") 22 | ), 23 | column(width = 3, bookmarkButton()) 24 | ), 25 | 26 | fluidRow(column(width = 7, 27 | plotOutput("simHist") 28 | ), 29 | column(width = 7, 30 | tableOutput("dataSummary") 31 | )) 32 | ) 33 | 34 | } 35 | 36 | 37 | 38 | server <- function(input, output, session){ 39 | 40 | data <- reactive({ 41 | 42 | rnorm(input$nSims) 43 | 44 | }) 45 | 46 | output$simHist <- renderPlot({ 47 | 48 | x <- data() 49 | qplot(x, bins = 20, fill = I(input$col)) 50 | 51 | }) 52 | 53 | output$dataSummary <- renderTable({ 54 | 55 | x <- data() 56 | tidy(summary(x)) 57 | 58 | }) 59 | 60 | } 61 | 62 | 63 | enableBookmarking(store = "url") 64 | shinyApp(ui, server) -------------------------------------------------------------------------------- /Exercises/09_Modules3/app.R: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Mango Solutions 3 | # Advanced Shiny 4 | # Exercise 9 - Modules 5 | #------------------------------------------------------------------------------# 6 | library(shiny) 7 | library(mangoTraining) 8 | source("columnByMonth.R") 9 | 10 | ui <- fluidPage( 11 | 12 | tabsetPanel( 13 | 14 | tabPanel("All Data", columnByMonthUI("allData")), 15 | tabPanel("Bakerloo", columnByMonthUI("Bakerloo")), 16 | tabPanel("Central", columnByMonthUI("Central")), 17 | tabPanel("Circle & Hammersmith", columnByMonthUI("CircleHam")), 18 | tabPanel("District", columnByMonthUI("District")), 19 | tabPanel("Jubilee", columnByMonthUI("Jubilee")), 20 | tabPanel("Metropolitan", columnByMonthUI("Metropolitan")), 21 | tabPanel("Northern", columnByMonthUI("Northern")), 22 | tabPanel("Piccadilly", columnByMonthUI("Piccadilly")), 23 | tabPanel("Victoria", columnByMonthUI("Victoria")), 24 | tabPanel("Waterloo & City", columnByMonthUI("Waterloo")) 25 | 26 | ) 27 | 28 | ) 29 | 30 | 31 | server <- function(input, output, session){ 32 | 33 | callModule(columnByMonth, "allData", data = tubeData) 34 | callModule(columnByMonth, "Bakerloo", data = filter(tubeData, Line == "Bakerloo")) 35 | callModule(columnByMonth, "Central", data = filter(tubeData, Line == "Central")) 36 | callModule(columnByMonth, "CircleHam", data = filter(tubeData, Line == "Circle & Ham")) 37 | callModule(columnByMonth, "District", data = filter(tubeData, Line == "District")) 38 | callModule(columnByMonth, "Jubilee", data = filter(tubeData, Line == "Jubilee")) 39 | callModule(columnByMonth, "Metropolitan", data = filter(tubeData, Line == "Metropolitan")) 40 | callModule(columnByMonth, "Northern", data = filter(tubeData, Line == "Northern")) 41 | callModule(columnByMonth, "Piccadilly", data = filter(tubeData, Line == "Piccadilly")) 42 | callModule(columnByMonth, "Victoria", data = filter(tubeData, Line == "Victoria")) 43 | callModule(columnByMonth, "Waterloo", data = filter(tubeData, Line == "Waterloo & City")) 44 | 45 | } 46 | 47 | shinyApp(ui, server) --------------------------------------------------------------------------------