r - structural holes and adjacency matrix -
i working on problem find measures related structure holes in r. problem when apply code below save adjacency matrix variable called "x" (copied source) adjacency matrix in r gives me error like:
"error in as.data.frame.default(d) : cannot coerce class ""igraph"" data.frame"
my code , data set looks data frame
s1 uid1 uid2 1 1 2 2 1 3 3 1 4 4 1 5 5 2 3 6 2 4 7 2 5 8 3 4 9 3 5 10 4 5 11 6 7 12 6 8 13 6 9 14 7 8 15 7 9 16 8 9 17 1 6 18 1 7 19 6 7
when apply code error becomes on here
x <- get.adjacency(graph.data.frame(graph.edgelist(as.matrix(s1), directed=f)))
error in as.data.frame.default(d) : cannot coerce class ""igraph"" data.frame
so use code structure holes measure
y <- index.egonet(x) #desired output code
you going
data.frame (s1) --> matrix --> graph via graph.edgelist --> trying create graph again via graph.data.frame
and that's why you're getting error, because have graph, , graph.data.frame()
expects data.frame
input, not igraph
object. that's error message saying:
error in as.data.frame.default(d) : cannot coerce class ""igraph"" data.frame
i.e - "don't give me 'igraph' object, want data.frame"
the end conclusion of - go source data.frame
igraph
object, extract adjacency matrix:
get.adjacency(graph.data.frame(s1, directed=f))
Comments
Post a Comment