无法获得igraph edgelist工作,ncol for matrix返回NULL

时间:2015-06-30 22:53:25

标签: r igraph

我遇到单行矩阵问题,我无法将其加载到有向图

> is.matrix(network_matrix)
[1] TRUE
> ncol(network_matrix)
[1] 3

第3列是重量,我想跳过它

> ncol(network_matrix[,1:2])
NULL

哪个好,但是:

g = graph.edgelist(network_matrix[,1:2], directed = TRUE)
E(g)$weight=as.numeric(network_matrix[,3])

我不明白为什么是NULL并且因为ncol(el)!= 2检查而阻止igraph structure.generators.R 代码运行。

这是我的代码,它处理以前的数据,我现在想要运行:

use strict;
use warnings;
use Text::ParseWords;

my $str = '06/14/2015,19:13:51,"Mrs, Nkoli,,,ka N,ebedo,,m" <ubabankoffice93@gmail.com>,1,2';
my @row = quotewords(',', 1, $str);
$row[2] =~ tr/,//d;
print join ",", @row;

谢谢!

1 个答案:

答案 0 :(得分:1)

必须设置drop = F

g = graph.edgelist(network_matrix[,1:2, drop=F], directed = TRUE)

感谢@ user20650

案件结束