我正在使用iGraph库进行工作,需要对网络进行一些统计分析。我正在使用iGraph计算几个变量,然后希望将这些指标作为因变量在几个回归中使用,并将顶点属性作为模型中的自变量。
我能够加载数据,运行igraph分析,但是将igraph对象转换回数据框时遇到了问题。我不需要保留边,只需要将每个顶点转换为一个观测值,并将属性作为每行中的列。
我尝试了以下方法:
但是它会抛出以下错误:
我能够加载数据,运行igraph分析,但是将igraph对象转换回数据框时遇到了问题。我不需要保留边,只需要将每个顶点转换为一个观测值,并将属性作为每行中的列。
我尝试了以下方法:
fg <- fastgreedy.community(uncompg, merges=TRUE)
z<-which.max(fg$modularity)
fgc<- community.to.membership(uncompg, fg$merges,z)
names<-array(V(uncompg)$name)
fccommunity<-array(fgc$membership)
fcresult<-as.matrix(cbind(names,fccommunity))
compg <- set.vertex.attribute(compg, "community", value=fccommunity)
uncompg<-simplify(as.undirected(compg))
hubscore<-hub.score(compg)$vector
authscore<-authority.score(compg)$vector
netdata<-as.data.frame(compg)
但是它会抛出以下错误:
cannot coerce class '"igraph"' into a data.frame
有任何帮助或指引吗?