我如何在Shiny中构建一个分层复选框选择面板,如下图所示?
有了这种选择清单:
choices<- c("I. Lorem ipsum","I.1. Lorem ipsum","I.1.1. Lorem ipsum","I.1.2. Lorem ipsum" ,
"I.2. Lorem ipsum","I.2.1 Lorem ipsum")
ui <-fluidPage(
checkboxGroupInput("variable","Variable:",choices)
)
server <- function(input, output, session) {
}
runApp(list(ui = ui, server = server))
答案 0 :(得分:5)
这是你想要的吗?
library(shiny)
library(shinyTree)
server <- shinyServer(function(input, output, session) {
output$tree <- renderTree({
list( 'I lorem impsum'= list(
'I.1 lorem impsum' = structure(list('I.1.1 lorem impsum'='1', 'I.1.2 lorem impsum'='2'),stselected=TRUE),
'I.2 lorem impsum' = structure(list('I.2.1 lorem impsum'='3'), stselected=TRUE)))
})
})
ui <- shinyUI(
shiny::fluidPage(
h4('Shiny hierarchical checkbox')
,shinyTree("tree", checkbox = TRUE)
)
)
shinyApp(ui, server)