Each column of hierarchy is one level of the tree, in that order: a
node for each value of the first column, under it a node for each value of
the second column found with it, and so on. A missing value ends the
branch there, which is how treeToDf writes a branch shorter
than the deepest one, so a tree survives the round trip. A row whose first
column is missing is left out.
Usage
dfToTree(df, hierarchy = colnames(df))Value
A named nested list, as renderTree takes; an empty
list for a data frame with no rows.
See also
treeToDf, the 22-dfToTree example
Author
Jasper Schelfhout jasper.schelfhout@openanalytics.eu
Examples
df <- data.frame(Titanic)
tree <- dfToTree(df, c("Sex", "Class", "Survived"))
str(tree$Male$`1st`)
#> List of 2
#> $ No : chr ""
#> $ Yes: chr ""