如何使用"get.adjacency()"保存邻接矩阵.在R中,使用iGraph和RStudio? [英] How to save a adjacency matrix with "get.adjacency()" in R, with iGraph and RStudio?

查看:550
本文介绍了如何使用"get.adjacency()"保存邻接矩阵.在R中,使用iGraph和RStudio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将"get.adjacency()"之后的邻接矩阵保存为R中的邻接矩阵?我尝试过

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

test <- get.adjacency(network)

但是我遇到了错误

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

我正在使用RStudio和iGraph软件包.

I´m using RStudio and the package iGraph.

推荐答案

尝试在对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"

这篇关于如何使用"get.adjacency()"保存邻接矩阵.在R中,使用iGraph和RStudio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆