How could I build in Shiny a hierarchical checkbox selection panel like the image below?
With this kind of list of choices:
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))
This is what you want?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With