问题
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