The reverse of dfToTree: one row per leaf, with the names on
the path down to it in the columns. A path shorter than the deepest one
leaves the remaining columns NA.
Examples
df <- data.frame(Titanic)
tree <- dfToTree(df, c("Sex", "Class", "Survived"))
newDf <- treeToDf(tree, c("Sex", "Class", "Survived"))
head(newDf)
#> Sex Class Survived
#> 1 Male 1st No
#> 2 Male 1st Yes
#> 3 Male 2nd No
#> 4 Male 2nd Yes
#> 5 Male 3rd No
#> 6 Male 3rd Yes