使用IGRAPHE创建二部图

使用IGRAPHE创建二部图,r,graph,igraph,bipartite,R,Graph,Igraph,Bipartite,我正在尝试使用以下矩阵创建一个二部图: G1 G2 G3 G4 G5 G6 virus1 0 1 1 0 1 0 virus2 1 1 0 0 0 0 virus3 0 1 0 0 0 0 virus4 1 0 0 0 0 0 virus5 0 1 0 1 0 1 virus6 1 1 0 1 0 0 以下是我目前使用的代码: install.p

我正在尝试使用以下矩阵创建一个二部图:

    G1  G2  G3  G4  G5  G6
virus1  0   1   1   0   1   0
virus2  1   1   0   0   0   0
virus3  0   1   0   0   0   0
virus4  1   0   0   0   0   0
virus5  0   1   0   1   0   1
virus6  1   1   0   1   0   0
以下是我目前使用的代码:

install.packages("igraph")
library(igraph)
matrice = read.table("C:/Users/loisv/Desktop/test4.txt",sep="\t", row.names=NULL,header=TRUE)
net2 <- graph_from_incidence_matrix(matrice)
plot(net2, vertex.size=7, layout=layout_as_bipartite)
install.packages(“igraph”)
图书馆(igraph)
matrice=read.table(“C:/Users/loisv/Desktop/test4.txt”,sep=“\t”,row.names=NULL,header=TRUE)

net2从
read.table
中删除
行.names=NULL
,谢谢您的回答,不幸的是,它没有改变任何东西…从您的数据映像中,您的行.names仍然存在错误。如果操作正确,则不应有列标题。请用更新的代码编辑您的问题以读取数据。您可能需要明确说明:
行。名称=1
以强制第一列为行名称。非常感谢!