More input types

Case Studies: Building Web Applications with Shiny in R

Dean Attali

Shiny Consultant

Gapminder plot app

chapter2_3_more_input_types.003.png

Case Studies: Building Web Applications with Shiny in R

Slider inputs

sliderInput("slider", "Choose a number",
            value = 15, min = 5, max = 20)

chapter2_3_more_input_types.004.png

sliderInput("slider2", "Choose a number",
            value = c(10, 15), min = 5, max = 20)

chapter2_3_more_input_types.006_b.png

str(input$slider2)
num [1:2] 10 15
Case Studies: Building Web Applications with Shiny in R

Radio buttons

radioButtons("radio", "Choose your favorite time of day",
             choices = c("Morning", "Afternoon", "Evening"),
             selected = "Afternoon")

chapter2_3_more_input_types.009.png

Case Studies: Building Web Applications with Shiny in R

Select inputs (dropdowns)

selectInput("select", "Choose your favorite time of day",
            choices = c("Morning", "Afternoon", "Evening"),
            selected = "Afternoon")

chapter2_3_more_input_types.013.png

Case Studies: Building Web Applications with Shiny in R

Select inputs (dropdowns)

selectInput("select", "Choose your favorite time of day",
            choices = c("Morning", "Afternoon", "Evening"),
            selected = "Afternoon")

chapter2_3_more_input_types.014.png

Case Studies: Building Web Applications with Shiny in R

Select inputs (dropdowns)

selectInput("select", "Choose your favorite time of day",
            choices = c("Morning", "Afternoon", "Evening"),
            selected = "Afternoon")

chapter2_3_more_input_types.015.png

Case Studies: Building Web Applications with Shiny in R

Select inputs (dropdowns)

  • Allow multiple selections
selectInput("select", "Choose your favorite time of day",
            choices = c("Morning", "Afternoon", "Evening"),
            selected = c("Afternoon", "Evening"),
            multiple = TRUE)

chapter2_3_more_input_types.016.png

Case Studies: Building Web Applications with Shiny in R

Radio buttons vs select inputs

  • Radio buttons
    • Few options
    • All options are visible
    • Exactly one option selected
  • Select inputs
    • Few or many options
    • Harder to see all options
    • Multiple options can be selected

chapter2_3_more_input_types.018.png

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...