2 모드 네트워크에서 다른 노드를 시각화하는 데 문제가 있습니다. 누군가가 실수를 찾도록 도울 수 있기를 바랍니다.
다음과 같은 관련 Q & A를 확인했습니다. How to create a bipartite network in R with igraph or tnet 또는 Converting data form for 2mode network in r 그러나 지침에 따라 문제를 해결할 수는 없습니다.두 모드 네트워크 노드의 색이 다릅니다.
그래서 여기에 내가 한 것입니다. 두 열 (위치 & 칭의)이있는 csv.file이 있습니다. 그것은 다음과 같습니다
title of the file: mydata.csv
id position justification
[1] contra solidarity legal regulations
[2] pro solidarity no justification
[3] pro solidarity political solidarity
[4] pro solidarity political solidarity
[5] pro solidarity legal regulations
... (in total, 620 observations/rows of 2 variables)
나는 r 작업 및 패키지 statnet & igraph 및 노드/정점에 대해 서로 다른 색으로 bipartite.graph을 만들려고합니다. R은 파일을 읽고 스크립트는 정상적으로 작동합니다 (오류 없음) :
EC_data <- read.csv("Mydata.csv", sep=";")
EC_data
library(statnet)
library(devtools)
euro_network <- network(EC_data, matrix.type="edgelist", sep=";")
euro_network
# overview about the network
summary(euro_network, print.adj=FALSE)
# for 2-mode networks
detach(package:statnet)
library(igraph)
# bipartite/2-mode network is created from edge lists
bn <- graph.data.frame(EC_data, directed=FALSE)
bn
# telling igraph that this is bipartite graph
V(bn)$type <- V(bn)$type %in% EC_data[,1]
bn
plot(bn)
# plotting the network
plot.igraph(bn,layout=layout.fruchterman.reingold)
# creating an vertex attribute to have different colors
V(bn)$type <- V(bn)$name %in% bn[,1]
bn
colors <- c("green", "red")
# green for 'contra solidarity', red for 'pro solidarity'
plot(bn, vertex.color=colors[V(bn)$type+1])
그러나 작동하지 않습니다. 모든 노드의 색깔이 같고 그 이유를 모르겠습니다. 또한 R과 igraph를 시작하기 때문에 근본적으로 무언가를 놓치거나 완전히 고려하지 않은 느낌이 들었습니다.
데이터 또는 스크립트의 문제점은 무엇입니까?
도움이나 제안을 매우 환영합니다!
감사를 사용해보십시오. 괜찮 았어! 그래서, 제 실수는 V (g) $ 타입 명령이었고 프로젝션을하지 않았습니다. 맞습니까? –