Показать описание в блестящей боковой панели

#r #shiny

#r #блестящий

Вопрос:

Как я могу показать описание в соответствии с вводом, который был выбран в блестящей боковой панели?

Вот часть моего кода:

 ui=pageWithSidebar(
  headerPanel("CC"),
  sidebarPanel(
    helpText("Create demographic"),
    selectInput("var", 
                label = "Choose a variable to display",
                choices = c("a", "b",
                            "c", "d"),
                selected = "a")
  ),
  mainPanel(fluidPage(
    ShinyCyJSOutput(outputId = 'cy')
  )
))

 

При выборе a, b, c или d я хочу, чтобы отображалось описание.

Ответ №1:

Вы могли бы использовать conditionalPanel s:

 library(shiny)

ui <- pageWithSidebar(
  headerPanel("CC"),
  sidebarPanel(
    helpText("Create demographic"),
    selectInput("var", 
                label = "Choose a variable to display",
                choices = c("a", "b",
                            "c", "d"),
                selected = "a"),
    conditionalPanel(condition = "input.var == 'a'",
                     tags$div("Explanation for variable a")),
    conditionalPanel(condition = "input.var == 'b'",
                     tags$div("Explanation for variable b"))
  ),
  mainPanel(fluidPage(
    
  )
)
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)