是否可以根据box
选择在发光的仪表板上显示selectInput()
?
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("sel","Select",c("Display","Not"))
),
dashboardBody(
box()
)
)
server <- function(input, output) { }
shinyApp(ui, server)
答案 0 :(得分:1)
要实现交互性,您需要在服务器代码中动态生成UI。
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("sel","Select",c("Display","Not"))
),
dashboardBody(
uiOutput("conditionalBox")
)
)
server <- function(input, output) {
output$conditionalBox <- renderUI({
if(input$sel == "Display"){
return(
box(title = "Display when choosing Display in #sel")
)
} else {
return(
NULL
)
}
})
}
shinyApp(ui, server)