Skip to content

Warning should be issued in FromDataFrameNetwork() when it deliberately creates duplicates of a single record #178

@telenskyt

Description

@telenskyt

The function FromDataFrameNetwork() will silently create duplicates of a single record (node named "c" in the example below) in case that it refers to parent node name which is duplicated in the tree (not among siblings, but among other nodes in the tree; node named "b" in the example below). The single node "c" will be added multiple times to the tree, silently, without any warning. I believe warning would be very desirable in this case, when check = "check" is set.

Here is the example:

d <- data.frame(ID = 1:5, parentID = c(0, 1, 1, 0, 2), nodeName = c("a", "b", "d", "b", "c"))
d$parentName <-  d[match(d$parentID, d$ID), "nodeName"]
d$parentName[is.na(d$parentName)] <- "/"
d

  ID parentID nodeName parentName
1  1        0        a          /
2  2        1        b          a
3  3        1        d          a
4  4        0        b          /
5  5        2        c          b

x <- FromDataFrameNetwork(d[,c("nodeName","parentName")])
print(x)

      levelName
1 /            
2  ¦--a        
3  ¦   ¦--b    
4  ¦   ¦   °--c
5  ¦   °--d    
6  °--b        
7      °--c 

The node "c" was added multiple times, because node "b" is not unique within the tree. I believe warning would be very desirable in this case.

Tested on data.tree package version 1.2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions