Description Usage Arguments Details Examples
Functions to check if an object is a treedf
, or coerce it if possible.
1 2 3 4 5 6 7 8 9 10 |
x |
An R object. |
... |
Passed to |
pathName |
The name of the column containing the path of the current node. If this column exists in |
pathDelimiter |
The delimiter used to separate nodes in |
A treedf
is a data.frame
in which each line defines a node in a tree and is characterised by columns
the unique identifier of the node,
the identifier of the parent of the node,
the (displayed) name of the node (optional),
logical, if TRUE, the node will be selected in checkboxTreeInput
(optional),
logical, if TRUE, the node will be opened in checkboxTreeInput
(optional).
The structure of the tree is therefore defined by the relationship between id
and parent_id
.
Conversion functions are provided for various tree structures available in R. If the structure of the tree is simply defined by different columns of a data.frame, one per level (e.g. organisation, department, team or family, genus, species), join them in pathString
and use this argument to convert the data.frame into a treedf (see examples).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # definition of a tree through id and parent_id
x <- data.frame(id=c(1, 2, 3, 4), parent_id=c(NA, 1, 2, 1))
ui <- fluidPage(checkboxTreeInput(inputId="tree", tree=x))
server <- function(input, output) { }
if (interactive()) shinyApp(ui, server)
# definition of a tree by levels
x <- data.frame(
organisation=rep(c("R", "MATLAB"), each=3),
department=c("code", "code", "doc", "code", "doc", "marketing"),
team=c("core", "graphics", "help", "central", "help", "bosses")
)
x$pathString <- paste(x$organisation, x$department, x$team, sep="/")
x <- as.treedf(x)
ui <- fluidPage(checkboxTreeInput(inputId="tree", tree=x))
if (interactive()) shinyApp(ui, server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.