Об'єднання всіх джерел слів

Case Studies: створення вебзастосунків із Shiny в R

Dean Attali

Shiny Consultant

Об'єднання всіх джерел слів

  • 3 джерела даних для хмари слів

    • Текстовий об'єкт: artofwar
    • Текст користувача: textAreaInput()
    • Текстовий файл: fileInput()
  • Далі: дозволити всі разом

    • Перемикачі (radio) для вибору джерела слів

Case Studies: створення вебзастосунків із Shiny в R

Перемикачі (radio) — повторення

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

Case Studies: створення вебзастосунків із Shiny в R

Перемикачі (radio) — додатково

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: створення вебзастосунків із Shiny в R

Умовні панелі

  • Показувати/ховати елементи UI залежно від значення вводу
conditionalPanel(condition, ...)
  • condition схожий на код R, але input$<id> замінюється на input.<id>
  • ... — будь-який UI
Case Studies: створення вебзастосунків із Shiny в R

Умовні панелі

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: створення вебзастосунків із Shiny в R

Давайте потренуємось!

Case Studies: створення вебзастосунків із Shiny в R

Preparing Video For Download...