Adding simple inputs to modify a plot

Case Studies: Building Web Applications with Shiny in R

Dean Attali

Shiny Consultant

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.003.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.004.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.005.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.006.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.007.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.008.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.009.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.010.png

Case Studies: Building Web Applications with Shiny in R

Gapminder plot app

chapter2_2_adding_simple_inputs_to_modify_a_plot.011.png

Case Studies: Building Web Applications with Shiny in R

Text inputs

ui <- fluidPage( 
    textInput(inputId = "package", 
              label = "What's your favourite R package?",
              value = "shiny")
)

server <- function(input, output) {}
shinyApp(ui, server)

chapter2_2_adding_simple_inputs_to_modify_a_plot.012.png

str(input$package)
chr "shiny"
Case Studies: Building Web Applications with Shiny in R

Numeric inputs

numericInput("years", "How many years have you been using R?",
             value = 4, min = 0, max = 25)

chapter2_2_adding_simple_inputs_to_modify_a_plot.014.png

str(input$years)
int 4
Case Studies: Building Web Applications with Shiny in R

Checkbox inputs

checkboxInput("agree", "I agree to the terms and conditions",
              value = TRUE)

chapter2_2_adding_simple_inputs_to_modify_a_plot.020.png

str(input$agree)
logi TRUE
Case Studies: Building Web Applications with Shiny in R

Let's practice!

Case Studies: Building Web Applications with Shiny in R

Preparing Video For Download...