Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as_treenetdf.data.frame should handle implicit root nodes better #225

Open
cjyetman opened this issue Dec 1, 2017 · 0 comments
Open

as_treenetdf.data.frame should handle implicit root nodes better #225

cjyetman opened this issue Dec 1, 2017 · 0 comments

Comments

@cjyetman
Copy link
Collaborator

cjyetman commented Dec 1, 2017

Ideally, data passed to as_treenetdf.data.frame should include information about every node, including the root node, such as...

library(networkD3)
data <- read.csv(header = T, text = "
nodeId,parentId
root,
L2-1,root
L2-2,root
L3-1,L2-1
L3-2,L2-1
L3-3,L2-2
L3-4,L2-2
")
as_treenetdf(data)

In some cases, a user may expect that the root node will be inferred from the data. This could be expected with numerous possibilities...

  1. root node is listed as the parentId of multiple child nodes, but not explicitly listed itself as a nodeId
library(networkD3)
data <- read.csv(header = T, text = "
nodeId,parentId
L2-1,root
L2-2,root
L3-1,L2-1
L3-2,L2-1
L3-3,L2-2
L3-4,L2-2
")
as_treenetdf(data)
  1. multiple nodes do not have a parentID node explicitly named, and therefore should be considered the children of a root node
library(networkD3)
data <- read.csv(header = T, text = "
nodeId,parentId
L2-1,
L2-2,
L3-1,L2-1
L3-2,L2-1
L3-3,L2-2
L3-4,L2-2
")
as_treenetdf(data)

or

library(networkD3)
data <- read.csv(header = T, text = "
nodeId,parentId
L2-1,NA
L2-2,NA
L3-1,L2-1
L3-2,L2-1
L3-3,L2-2
L3-4,L2-2
")
as_treenetdf(data)

It could be that the data represent two separate branches and do not share a root node, but since the plotting function does not support plotting two separate branches, maybe it's safe to assume there's a shared root node?

I noticed this problem while investigating the example given in #224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant