Search code examples
rigraphegor

Why is the ego.attrs argument in as_igraph not converting ego information correctly?


I have a set of networks as egor objects in a list. When I convert them to a list of igraph objects using as_igraph, I include the ego.attrs argument to keep the data on the ego. I notice that the data is not correct when comparing between the egor and the igraph objects. Here's some reproducible code using the datasets provided by the egor package:

library(egor)
library(igraph)

data("alters32")
data("egos32")
data("aaties32")
e1 <- egor(alters = alters32,
           egos = egos32,
           aaties = aaties32,
           ID.vars = list(
             ego = ".EGOID",
             alter = ".ALTID",
             source = ".SRCID",
             target = ".TGTID"))

j <- e1$ego %>%
  filter(.egoID == "4") 
j$sex
j$country
j$age
# This says w, Poland, 18-25

# Convert to igraph
igraph.egolist <- e1 %>%
  as_igraph(include.ego = TRUE,
            ego.attrs = c("sex","country", "age")) ## This lets me keep the ego attributes


h <- igraph.egolist[["4"]]
V(h)[name == "ego"]$sex 
V(h)[name == "ego"]$country 
V(h)[name == "ego"]$age 
# this says m, Germany, 56-65

Am I doing something wrong, or is this an issue with the package itself?


Solution

  • This is a bug in the current egor CRAN version. I updated the egor development version with a fix for this. remotes::install_github(repo="tilltnet/egor"). An update including this fix will be submitted to CRAN soon.