-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
I encountered scenario where using Set(name = ..) was the only workaround, while not noticing that node names are not unique among siblings. That resulted in the tree structure being invalid without knowing, and then resulted in an error when the tree was printed.
I believe the Set(name = ..) method should check for consistency and report errors.
Here is the scenario - it is a similar case and similar motivation as in #180, but with a different data:
d <- data.frame(ID = 1:6, parentID = c(0, 1, 1, 0, 2, 0), nodeName = c("a", "b", "d", "b", "c", "a"))
d$parentName <- d[match(d$parentID, d$ID), "nodeName"]
d
ID parentID nodeName parentName
1 1 0 a <NA>
2 2 1 b a
3 3 1 d a
4 4 0 b <NA>
5 5 2 c b
6 6 0 a <NA>
x <- FromDataFrameNetwork(d[,c("ID", "parentID", "nodeName")])
nam <- x$Get("nodeName")
nam[is.na(nam)] <- ""
x$Set(name = nam)
print(x)
Error in if (self$position == self$parent$count) mySeparator <- paste0(self$root$printFormatters$s, :
the condition has length > 1
Tested on data.tree package version 1.2.0.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels