Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny hierarchical nested checkboxGroupInput

How could I build in Shiny a hierarchical checkbox selection panel like the image below? enter image description here

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))
like image 913
GPierre Avatar asked Jun 02 '15 09:06

GPierre


1 Answers

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)
like image 126
Eduardo Bergel Avatar answered Oct 18 '22 21:10

Eduardo Bergel