How can I open .net files with package sna in R?

纵然是瞬间 提交于 2019-12-08 12:59:34

问题


I have a lot of .net files, and the package tutorial says it is possible to use this format with sna.

My error message is:

> Error in FUN(X[[1L]], ...) :    as.edgelist.sna input must be an
> adjacency matrix/array, edgelist matrix, network, or sparse matrix, or
> list thereof.

How can I open .net files with sna package in R? I browsed the net but I couldn't find any helpful information to my problem.

I have no problem with using package igraph, but there are some pros to use package sna, too.

Thank you in advance.

P.S. I tried to read pajek with library(network):

b1<- read.paj("15.net")
Warning message:
In readLines(file, 1, ok = TRUE) : incomplete final line found on '15.net'

回答1:


If it works with 'igraph', do it with 'igraph'. Then convert the data to a form acceptable by functions in the 'sna' package. For example with asNetwork function from package 'intergraph' you can convert igraph object to a network object (package 'network'), which you can use with 'sna'.



来源:https://stackoverflow.com/questions/36239085/how-can-i-open-net-files-with-package-sna-in-r

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