0

I am trying to create a tree/ontology/dendrogram (using either ggraph or igraph) from a dataset that has three columns and thus three distinct branches:

df <- data.frame(
           parent = c("a", "a", "a", "b", "b", "c"), 
           child1 = c("ax", "ax", "ay", "bx", "by", "cx"),
           child2 = c("ax1", "ax2", "ay1", "bx1", "by1", "cx1")
           )

How do I go about creating edge and node columns when I have three levels to the hierarchy?

Thanks!

Thomas J. Brailey
  • 151
  • 1
  • 2
  • 12

1 Answers1

0

The package collapsibleTree can be used for trees with multiple nodes.

collapsibleTree::collapsibleTree(df, hierarchy = c("parent", "child1"), height = 600, width = 600, collapse = FALSE)
Thomas J. Brailey
  • 151
  • 1
  • 2
  • 12