我试图显示用户之间的关系(基于角色),我想根据他们的团队为他们着色。我有以下代码;
#get library's
install.packages("igraph")
library("igraph")
install.packages('reshape')
library(reshape)
#connecting to DB
data <- rxDataStep(dsSqlServerData)
head(data)
users <- rxDataStep(dsSqlServerData)
head(users)
#making the matrix
data1<-cast(data, acentralacc ~ bcentralacc, value="rol",fun.aggregate= length)
net2 <- graph_from_incidence_matrix(data1)
net2.bp <- bipartite.projection(net2)
head(net2.bp$proj1,4)
head(net2)
#making the plot
pal2 <- rainbow(5, alpha=.5)
#plot(net2.bp$proj1,margin = 0,vertex.size=5,vertex.label="",vertex.color=pal2) #only shows very little data points
plot(net2,margin = 0,vertex.size=5,vertex.label="",vertex.color=pal2)
legend("topleft", c(users$Team), pch=21,col="#777777", pt.bg=pal2, pt.cex=2, cex=.8, bty="n", ncol=1)
dataframe:data:metadata
dataframe:users:metadata
我遇到的一个问题是我有很多数据点(3000 ish)。
我尝试与团队一起获得传奇。我的猜测是,由于不知道2个表之间的关系
,因此无法呈现传说legend("topleft", c(users$Team), pch=21,col="#777777", pt.bg=pal2, pt.cex=2, cex=.8, bty="n", ncol=1)
为剧情着色,我需要为每个团队提供相同的颜色
vertex.color=pal2