Je veux tracer un objet réseau en utilisant GGally ou ggnetwork et je veux être capable de produire une disposition où les nœuds sont groupés par un attribut vertex. J'ai passé un certain temps à chercher un moyen de le faire, mais je n'ai pas compris. Les nœuds peuvent-ils être groupés dans la mise en page par attribut, de sorte que tous les nœuds avec l'attribut «a» sont dans un cluster, les nœuds avec l'attribut «b» dans un cluster, etc.?Comment grouper des nœuds par l'attribut vertex dans ggnet2 ou ggnetwork
Merci d'avance.
Voici deux exemples:
library (GGally)
library (ggnetwork)
library (ggplot2)
library (sna)
library (network)
#make a random network with some vertex attributes
abc<-as.network(rgraph(20,1))
abc %v% "kinds" <- letters[1:3]
abc %v% "model" <- LETTERS[12:18]
#plot the network using ggnet2 in library (GGally)
#I want to somehow group the nodes together by a vertex attribute.
#Here I have tried to group nodes by "kinds." How to do this??
ggnet2(abc,
size="degree", size.cut=3,
color = "kinds",
group = "kinds")
#and here is an example using library (ggnetwork)
#set degree as an attribute to call in ggnetwork.
#I could not figure out another way to set size = degree without first
#passing it as a vertex attribute.
abc %v% "deg_4ggnet"<-degree(abc)
abc2<-ggnetwork(abc)
ggplot(abc2, aes(x = x, y = y, xend = xend, yend = yend))+
geom_edges(color = "black") +
geom_nodes(aes(color = kinds, size = deg_4ggnet)) +
theme_blank()
#How to group by vertex attribute "kinds"???
Consultez ce post: http://stackoverflow.com/q/28693826/4488105 – paqmo