How to save a adjacency matrix with “get.adjacency()” in R, with iGraph and RStudio?

只谈情不闲聊 提交于 2019-12-13 13:47:01

问题


is it possible to save an adjacency matrix after "get.adjacency()" as an adjacency matrix in R? I tried

test <- get.adjacency(network)

but I´m getting the error

Error in View : cannot coerce class "structure("dgCMatrix", package = "Matrix")" to a data.frame. 

I´m using RStudio and the package iGraph.


回答1:


Try using sparse=FALSE in the call to get.adjacency(...)

g <- graph.full(5)
test <- get.adjacency(g)
class(test)
# [1] "dgCMatrix"
# attr(,"package")
# [1] "Matrix"

test <- get.adjacency(g,sparse=FALSE)
class(test)
# [1] "matrix"


来源:https://stackoverflow.com/questions/24597837/how-to-save-a-adjacency-matrix-with-get-adjacency-in-r-with-igraph-and-rstu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!