自定义默认 treeNetwork 以折叠并包含 nodeID

Customise default treeNetwork to collapse and include nodeID

关于treeNetwork的几个问题。

是否可以将networkD3 中的treeNetwork 设置为默认折叠? 我的层次结构树有 6 个级别,所以我不希望一开始就显示所有分支。

我还想在每个节点上显示 nodeID 名称,但看不到此选项。可能吗?

最后,可能更复杂,但是否可以单击较低级别的节点并重组树,以便该级别成为新的根?

Is it possible to set the treeNetwork from networkD3 to be collapsed by default?

没有

is it possible to click a node at a lower level and have the tree restructure so that level becomes the new root?

没有

I would also like to show the nodeID name on each node but cannot see the option for this. Is it possible?

这是默认行为...

# devtools::install_github("christophergandrud/networkD3")
library(networkD3)

tree <- read.csv(header = TRUE, stringsAsFactors = FALSE, text = "
nodeId,parentId,name
1,,one
2,1,two
3,1,three
4,2,four
5,2,five
6,3,six
7,3,seven
")

treeNetwork(tree)