Closed raffaelevacca closed 4 years ago
This might be fixed by adding the missing alter IDs from d
into the vertices
data frame (with all their attributes set to NA
) before converting to igraph via graph_from_data_frame
.
This is an issue that I worked on before without finding a satisfying solution.
The way this should be handled by egor
is that an error would be raised at the time of creation of the egor
object, when alter-alter ties are referencing non-existing alters. Including a check for this in egor()
is pretty straightforward, but it'll break some of the import functions and vignettes. I'll look into it.
This might be fixed by adding the missing alter IDs from
d
into thevertices
data frame (with all their attributes set toNA
) before converting to igraph viagraph_from_data_frame
.
This solution would help when the mismatch between alter and alter-alter tie data was intended. In cases where the mismatch is unintended (/unnoticed) egor
would mask existing data problems, by giving the impression that everything is working. Making the user aware of the issue only when as_igraph()
is used is also not good though. I will therefore implement the behavior described above (make egor()
fail on data mismatch).
If throwing an error when the user tries to create the egor
object breaks existing code, another option is giving just a warning. The function could still make the egor
object (with a warning) by adding the missing alters to the alter attribute data with all attributes set to NA.
It works now. All test complete, but I might have introduced new issues, we'll see.
It is really important, that the the IDs are consistent on every level, as filtering the egor
object will otherwise lead to unexpected drops of cases with inconsistent IDs. There were already some checks for ID consistency, with this one in place we should be good on this front now.
There are cases in which the alter-tie edge list data frame (say
atie.data
) includes alter IDs that do not appear in the alter attribute data frame (sayalter.data
). This may not be ideal but it's the case with some data in which certain alters in the edge list have missing attributes.When this happens,
egor(alters = alter.data, egos = foo, aaties = atie.data)
correctly creates theegor
object. However, when we applyas_igraph()
to that object, this throws an error (screenshot below). The error happens inigraph::graph.data.frame(d, vertices)
(now actually calledigraph::graph_from_data_frame
), which does not accept an edge list (d
) with alter IDs that do not appear in the alter attribute data (vertices
).