checkboxTreeInput: Convert a tree data.frame into a ul list

Description Usage Arguments Value Examples

View source: R/checkboxTreeInput.R

Description

Convert a tree data.frame into a ul list

Usage

1
2
checkboxTreeInput(inputId, label = NULL, tree, selected = NULL,
  opened = NULL)

Arguments

inputId

The input slot that will be used to access the value.

label

Display label for the control, or NULL for no label.

tree

a treedf data.frame defining a tree, with columns id and parent_id at least.

selected

The nodes that should be initially selected, if any. All selected nodes (and their ancestors) will also be opened, to be visible.

opened

The nodes that should be initially opened, if any. All ancestor nodes will also be opened.

Value

A list of HTML elements that can be added to a UI definition.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
tree <- data.frame(id=1:3, parent_id=c(NA, 1, 2))
checkboxTreeInput("foo", tree=tree)
checkboxTreeInput("foo", tree=tree, selected=3)
if (interactive()) {
tree <- data.frame(id=1:6, parent_id=c(NA, 1, 2, 2, NA, 1))
ui <- fluidPage(
  checkboxTreeInput(inputId="tree", label="Tree selector",
    tree=tree, selected=c(1, 6), opened=1
  ),
  verbatimTextOutput("selected")
)
server <- function(input, output, session) {
  output$selected <- renderPrint( input$tree )
}
shinyApp(ui, server)
}

jiho/checkboxTreeInput documentation built on June 13, 2020, 10:29 a.m.