Skip to contents

Extract the nodes from the tree that are checked in a more convenient format. You can choose which format you prefer.

Usage

get_checked(
  tree,
  format = c("names", "slices", "classid"),
  leaves_only = FALSE
)

Arguments

tree

The input$tree shinyTree you want to inspect.

format

In which format you want the output. Use names to get a simple list of the names (with attributes describing the node's ancestry), or slices to get a list of lists, each of which is a slice of the list used to get down to the checked node. classid gives each name with its stclass, stid and id (jsTree's id for the node) attributes instead of its ancestry.

leaves_only

If TRUE, return only checked nodes that have no children, leaving out checked parents. With three_state = TRUE a parent is checked whenever all of its children are, so this gives just the items that were ticked.

Value

A list with one element per checked node, descendants before their ancestors, in the form format gives. An empty list if nothing is checked or tree is NULL.

See also

Examples

tree <- list(
  Fruit = structure(list(
    Apple = structure(0, stchecked = TRUE),
    Pear = 0
  ), stopened = TRUE)
)
unlist(get_checked(tree))
#> [1] "Apple"