Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中使用asIgraph()函数将网络对象转换为igraph对象时出错?_R_Igraph - Fatal编程技术网

在R中使用asIgraph()函数将网络对象转换为igraph对象时出错?

在R中使用asIgraph()函数将网络对象转换为igraph对象时出错?,r,igraph,R,Igraph,我目前正在尝试将网络对象转换为igraph对象。从各种帖子中,我了解到intergraph包可以通过asIgraph()函数实现这一点。我正在尝试转换经典的Sampson数据集,它位于ergm包中。当我这样做时: > library(ergm) > library(intergraph) > library(igraph) > data(sampson) > class(samplike) # The network object [1] "network" >

我目前正在尝试将网络对象转换为igraph对象。从各种帖子中,我了解到
intergraph
包可以通过
asIgraph()
函数实现这一点。我正在尝试转换经典的Sampson数据集,它位于
ergm
包中。当我这样做时:

> library(ergm)
> library(intergraph)
> library(igraph)
> data(sampson)
> class(samplike) # The network object
[1] "network"
> asIgraph(samplike)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 88, 26
我有上面的错误。有人知道这个规范数据集为什么失败吗

编辑:查看两周前在
ergm
GitHub上发布的最新帖子 这是sampson数据集中的一个错误,现已修复 GitHub版本,但尚未更新为CRAN

它之所以失败,是因为
sampson
数据集有一个edge属性
namignations
,该属性只有26个值,即使数据集中有88个边。当
intergraph
尝试转换为
igraph
时,它尝试使用
asDF()
将边缘属性绑定到边缘列表,但此步骤失败。简单的方法是删除边属性,如下所示:

smplk<-samplike

delete.edge.attribute(smplk, "nominations")

asIgraph(smplk)

IGRAPH dca72f1 D--- 18 88 -- 
+ attr: cloisterville (v/l), group (v/c), na (v/l), vertex.names
| (v/c), na (e/l)
...
smplk