Combining all the word sources

Case Studies: Building Web Applications with Shiny in R

Dean Attali

Shiny Consultant

Combining all the word sources

  • 3 data sources for word cloud

    • Text object: artofwar
    • User text: textAreaInput()
    • Text file: fileInput()
  • Next step: allow all together

    • Radio buttons to select word source

Case Studies: Building Web Applications with Shiny in R

Radio buttons - review

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

Case Studies: Building Web Applications with Shiny in R

Radio buttons - advanced

radioButtons(
    "time_of_day", "Choose your favorite time of day",
    choices = c("I'm a morning person!" = "Morning",
                "Love my afternoons"    = "Afternoon",
                "Night owl here!"       = "Evening"),
    selected = "Afternoon"
)

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

Conditional panels

  • Show/hide UI elements based on input value
conditionalPanel(condition, ...)
  • condition is similar to R code, but input$<id> is replaced by input.<id>
  • ... is any UI
Case Studies: Building Web Applications with Shiny in R

Conditional panels

ui <- fluidPage(
  radioButtons("time_of_day",
               "Choose your favorite time of day",
               ...),

  plotOutput("morning_only_plot")
)
ui <- fluidPage(
  radioButtons("time_of_day",
               "Choose your favorite time of day",
               ...),

  conditionalPanel(
    condition = "input.time_of_day == 'Morning'",
    plotOutput("morning_only_plot")
  )
)
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...